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