aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2019-08-06 11:57:02 +0200
committerDaniel Stenberg <daniel@haxx.se>2019-08-07 14:45:44 +0200
commit640b9733de74d629af68afcad0ff8bb658e80eff (patch)
tree2a6b8f44a26baf7829246658f11489422cee615a /src
parentd39ae9d493f5e3abc1241d6e7ff89a885be1387a (diff)
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
Diffstat (limited to 'src')
-rw-r--r--src/tool_operate.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/tool_operate.c b/src/tool_operate.c
index 923b5a99d..01ee20061 100644
--- a/src/tool_operate.c
+++ b/src/tool_operate.c
@@ -496,6 +496,8 @@ static CURLcode post_transfer(struct GlobalConfig *global,
}
if(retry) {
+ long sleeptime = 0;
+ curl_off_t retry_after = 0;
static const char * const m[]={
NULL,
"timeout",
@@ -504,13 +506,24 @@ static CURLcode post_transfer(struct GlobalConfig *global,
"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 "
"Will retry in %ld seconds. "
"%ld retries left.\n",
m[retry], per->retry_sleep/1000L, per->retry_numretries);
- tool_go_sleep(per->retry_sleep);
per->retry_numretries--;
+ tool_go_sleep(sleeptime);
if(!config->retry_delay) {
per->retry_sleep *= 2;
if(per->retry_sleep > RETRY_SLEEP_MAX)