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
39# DEFAULT
40
41Zero if there was no header.
42
43# %PROTOCOLS%
44
45# EXAMPLE
46
47~~~c
48int main(void)
49{
50  CURL *curl = curl_easy_init();
51  if(curl) {
52    CURLcode res;
53    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
54    res = curl_easy_perform(curl);
55    if(res == CURLE_OK) {
56      curl_off_t wait = 0;
57      curl_easy_getinfo(curl, CURLINFO_RETRY_AFTER, &wait);
58      if(wait)
59        printf("Wait for %" CURL_FORMAT_CURL_OFF_T " seconds\n", wait);
60    }
61    curl_easy_cleanup(curl);
62  }
63}
64~~~
65
66# %AVAILABILITY%
67
68# RETURN VALUE
69
70Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
71