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
13---
14
15# NAME
16
17CURLINFO_RETRY_AFTER - returns the Retry-After retry delay
18
19# SYNOPSIS
20
21~~~c
22#include <curl/curl.h>
23
24CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_RETRY_AFTER,
25                           curl_off_t *retry);
26~~~
27
28# DESCRIPTION
29
30Pass a pointer to a curl_off_t variable to receive the number of seconds the
31HTTP server suggests the client should wait until the next request is
32issued. The information from the "Retry-After:" header.
33
34While the HTTP header might contain a fixed date string, the
35CURLINFO_RETRY_AFTER(3) always returns the number of seconds to wait -
36or zero if there was no header or the header could not be parsed.
37
38# DEFAULT
39
40Returns zero delay if there was no header.
41
42# EXAMPLE
43
44~~~c
45int main(void)
46{
47  CURL *curl = curl_easy_init();
48  if(curl) {
49    CURLcode res;
50    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
51    res = curl_easy_perform(curl);
52    if(res == CURLE_OK) {
53      curl_off_t wait = 0;
54      curl_easy_getinfo(curl, CURLINFO_RETRY_AFTER, &wait);
55      if(wait)
56        printf("Wait for %" CURL_FORMAT_CURL_OFF_T " seconds\n", wait);
57    }
58    curl_easy_cleanup(curl);
59  }
60}
61~~~
62
63# AVAILABILITY
64
65Added in 7.66.0
66
67# RETURN VALUE
68
69Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
70