mirror of
https://github.com/moparisthebest/curl
synced 2024-11-15 22:15:13 -05:00
curl: make use of CURLINFO_RETRY_AFTER when retrying
If a Retry-After: header was used in the response, that value overrides other retry timing options. Fixes #3794 Closes #4195
This commit is contained in:
parent
d39ae9d493
commit
640b9733de
@ -14,4 +14,7 @@ for all forthcoming retries it will double the waiting time until it reaches
|
|||||||
using --retry-delay you disable this exponential backoff algorithm. See also
|
using --retry-delay you disable this exponential backoff algorithm. See also
|
||||||
--retry-max-time to limit the total time allowed for retries.
|
--retry-max-time to limit the total time allowed for retries.
|
||||||
|
|
||||||
|
Since curl 7.66.0, curl will comply with the Retry-After: response header if
|
||||||
|
one was present to know when to issue the next retry.
|
||||||
|
|
||||||
If this option is used several times, the last one will be used.
|
If this option is used several times, the last one will be used.
|
||||||
|
@ -496,6 +496,8 @@ static CURLcode post_transfer(struct GlobalConfig *global,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(retry) {
|
if(retry) {
|
||||||
|
long sleeptime = 0;
|
||||||
|
curl_off_t retry_after = 0;
|
||||||
static const char * const m[]={
|
static const char * const m[]={
|
||||||
NULL,
|
NULL,
|
||||||
"timeout",
|
"timeout",
|
||||||
@ -504,13 +506,24 @@ static CURLcode post_transfer(struct GlobalConfig *global,
|
|||||||
"FTP error"
|
"FTP error"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
sleeptime = per->retry_sleep;
|
||||||
|
if(RETRY_HTTP == retry) {
|
||||||
|
curl_easy_getinfo(curl, CURLINFO_RETRY_AFTER, &retry_after);
|
||||||
|
if(retry_after) {
|
||||||
|
/* store in a 'long', make sure it doesn't overflow */
|
||||||
|
if(retry_after > LONG_MAX/1000)
|
||||||
|
sleeptime = LONG_MAX;
|
||||||
|
else
|
||||||
|
sleeptime = (long)retry_after * 1000; /* milliseconds */
|
||||||
|
}
|
||||||
|
}
|
||||||
warnf(config->global, "Transient problem: %s "
|
warnf(config->global, "Transient problem: %s "
|
||||||
"Will retry in %ld seconds. "
|
"Will retry in %ld seconds. "
|
||||||
"%ld retries left.\n",
|
"%ld retries left.\n",
|
||||||
m[retry], per->retry_sleep/1000L, per->retry_numretries);
|
m[retry], per->retry_sleep/1000L, per->retry_numretries);
|
||||||
|
|
||||||
tool_go_sleep(per->retry_sleep);
|
|
||||||
per->retry_numretries--;
|
per->retry_numretries--;
|
||||||
|
tool_go_sleep(sleeptime);
|
||||||
if(!config->retry_delay) {
|
if(!config->retry_delay) {
|
||||||
per->retry_sleep *= 2;
|
per->retry_sleep *= 2;
|
||||||
if(per->retry_sleep > RETRY_SLEEP_MAX)
|
if(per->retry_sleep > RETRY_SLEEP_MAX)
|
||||||
|
Loading…
Reference in New Issue
Block a user