1--- 2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3SPDX-License-Identifier: curl 4Title: CURLINFO_RETRY_AFTER 5Section: 3 6Source: libcurl 7See-also: 8 - CURLOPT_HEADERFUNCTION (3) 9 - CURLOPT_STDERR (3) 10 - curl_easy_header (3) 11Protocol: 12 - All 13Added-in: 7.66.0 14--- 15 16# NAME 17 18CURLINFO_RETRY_AFTER - returns the Retry-After retry delay 19 20# SYNOPSIS 21 22~~~c 23#include <curl/curl.h> 24 25CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_RETRY_AFTER, 26 curl_off_t *retry); 27~~~ 28 29# DESCRIPTION 30 31Pass a pointer to a curl_off_t variable to receive the number of seconds the 32HTTP server suggests the client should wait until the next request is 33issued. The information from the "Retry-After:" header. 34 35While the HTTP header might contain a fixed date string, the 36CURLINFO_RETRY_AFTER(3) always returns the number of seconds to wait - 37or zero if there was no header or the header could not be parsed. 38 39This option used to return a negative wait time if the server provided a date 40in the past. Since 8.12.0, a negative wait time is returned as zero. In any 41case we recommend checking that the wait time is within an acceptable range for 42your circumstance. 43 44# DEFAULT 45 46Zero if there was no header. 47 48# %PROTOCOLS% 49 50# EXAMPLE 51 52~~~c 53int main(void) 54{ 55 CURL *curl = curl_easy_init(); 56 if(curl) { 57 CURLcode res; 58 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); 59 res = curl_easy_perform(curl); 60 if(res == CURLE_OK) { 61 curl_off_t wait = 0; 62 curl_easy_getinfo(curl, CURLINFO_RETRY_AFTER, &wait); 63 if(wait) 64 printf("Wait for %" CURL_FORMAT_CURL_OFF_T " seconds\n", wait); 65 } 66 curl_easy_cleanup(curl); 67 } 68} 69~~~ 70 71# %AVAILABILITY% 72 73# RETURN VALUE 74 75curl_easy_getinfo(3) returns a CURLcode indicating success or error. 76 77CURLE_OK (0) means everything was OK, non-zero means an error occurred, see 78libcurl-errors(3). 79