mirror of
https://github.com/Sude-/lgogdownloader.git
synced 2025-02-02 05:52:31 +01:00
Added --wait option to set delay for http requests
May help with some errors that could be caused by too many requests in short time
This commit is contained in:
parent
dee83494c0
commit
f25c37074a
@ -52,6 +52,7 @@ class Config
|
|||||||
unsigned int iInstallerType;
|
unsigned int iInstallerType;
|
||||||
unsigned int iInstallerLanguage;
|
unsigned int iInstallerLanguage;
|
||||||
int iRetries;
|
int iRetries;
|
||||||
|
int iWait;
|
||||||
size_t iChunkSize;
|
size_t iChunkSize;
|
||||||
curl_off_t iDownloadRate;
|
curl_off_t iDownloadRate;
|
||||||
long int iTimeout;
|
long int iTimeout;
|
||||||
|
4
main.cpp
4
main.cpp
@ -154,6 +154,7 @@ int main(int argc, char *argv[])
|
|||||||
("insecure", bpo::value<bool>(&bInsecure)->zero_tokens()->default_value(false), "Don't verify authenticity of SSL certificates")
|
("insecure", bpo::value<bool>(&bInsecure)->zero_tokens()->default_value(false), "Don't verify authenticity of SSL certificates")
|
||||||
("timeout", bpo::value<long int>(&config.iTimeout)->default_value(10), "Set timeout for connection\nMaximum time in seconds that connection phase is allowed to take")
|
("timeout", bpo::value<long int>(&config.iTimeout)->default_value(10), "Set timeout for connection\nMaximum time in seconds that connection phase is allowed to take")
|
||||||
("retries", bpo::value<int>(&config.iRetries)->default_value(3), "Set maximum number of retries on failed download")
|
("retries", bpo::value<int>(&config.iRetries)->default_value(3), "Set maximum number of retries on failed download")
|
||||||
|
("wait", bpo::value<int>(&config.iWait)->default_value(0), "Time to wait between requests (milliseconds)")
|
||||||
;
|
;
|
||||||
// Options read from config file
|
// Options read from config file
|
||||||
options_cfg_only.add_options()
|
options_cfg_only.add_options()
|
||||||
@ -206,6 +207,9 @@ int main(int argc, char *argv[])
|
|||||||
if (config.sOrphanRegex.empty())
|
if (config.sOrphanRegex.empty())
|
||||||
config.sOrphanRegex = orphans_regex_default;
|
config.sOrphanRegex = orphans_regex_default;
|
||||||
|
|
||||||
|
if (config.iWait > 0)
|
||||||
|
config.iWait *= 1000;
|
||||||
|
|
||||||
config.bVerifyPeer = !bInsecure;
|
config.bVerifyPeer = !bInsecure;
|
||||||
config.bColor = !bNoColor;
|
config.bColor = !bNoColor;
|
||||||
config.bUnicode = !bNoUnicode;
|
config.bUnicode = !bNoUnicode;
|
||||||
|
@ -1402,6 +1402,7 @@ std::string Downloader::getResponse(const std::string& url)
|
|||||||
CURLcode result;
|
CURLcode result;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
usleep(config.iWait); // Delay the request by specified time
|
||||||
result = curl_easy_perform(curlhandle);
|
result = curl_easy_perform(curlhandle);
|
||||||
response = memory.str();
|
response = memory.str();
|
||||||
memory.str(std::string());
|
memory.str(std::string());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user