mirror of
https://github.com/Sude-/lgogdownloader.git
synced 2024-11-20 03:39:17 +01:00
Add support for retry and wait to Galaxy API and downloader API
This commit is contained in:
parent
df628b2a59
commit
9bd416e3b0
16
src/api.cpp
16
src/api.cpp
@ -242,9 +242,19 @@ std::string API::getResponse(const std::string& url)
|
||||
curl_easy_setopt(curlhandle, CURLOPT_NOPROGRESS, 1);
|
||||
curl_easy_setopt(curlhandle, CURLOPT_WRITEFUNCTION, writeMemoryCallback);
|
||||
curl_easy_setopt(curlhandle, CURLOPT_WRITEDATA, &memory);
|
||||
CURLcode result = curl_easy_perform(curlhandle);
|
||||
std::string response = memory.str();
|
||||
memory.str(std::string());
|
||||
|
||||
int retries = 0;
|
||||
CURLcode result;
|
||||
std::string response;
|
||||
do
|
||||
{
|
||||
if (Globals::globalConfig.iWait > 0)
|
||||
usleep(Globals::globalConfig.iWait); // Delay the request by specified time
|
||||
result = curl_easy_perform(curlhandle);
|
||||
response = memory.str();
|
||||
memory.str(std::string());
|
||||
}
|
||||
while ((result != CURLE_OK) && response.empty() && (retries++ < Globals::globalConfig.iRetries));
|
||||
|
||||
if (result == CURLE_HTTP_RETURNED_ERROR)
|
||||
{
|
||||
|
@ -117,9 +117,19 @@ std::string galaxyAPI::getResponse(const std::string& url, const bool& zlib_deco
|
||||
curl_easy_setopt(curlhandle, CURLOPT_NOPROGRESS, 1);
|
||||
curl_easy_setopt(curlhandle, CURLOPT_WRITEFUNCTION, galaxyAPI::writeMemoryCallback);
|
||||
curl_easy_setopt(curlhandle, CURLOPT_WRITEDATA, &memory);
|
||||
curl_easy_perform(curlhandle);
|
||||
std::string response = memory.str();
|
||||
memory.str(std::string());
|
||||
|
||||
int retries = 0;
|
||||
CURLcode result;
|
||||
std::string response;
|
||||
do
|
||||
{
|
||||
if (Globals::globalConfig.iWait > 0)
|
||||
usleep(Globals::globalConfig.iWait); // Delay the request by specified time
|
||||
result = curl_easy_perform(curlhandle);
|
||||
response = memory.str();
|
||||
memory.str(std::string());
|
||||
}
|
||||
while ((result != CURLE_OK) && response.empty() && (retries++ < Globals::globalConfig.iRetries));
|
||||
|
||||
curl_easy_setopt(curlhandle, CURLOPT_HTTPHEADER, NULL);
|
||||
curl_slist_free_all(header);
|
||||
|
Loading…
Reference in New Issue
Block a user