1CURLOPT_MAXREDIRS(3)       curl_easy_setopt options       CURLOPT_MAXREDIRS(3)
2
3
4

NAME

6       CURLOPT_MAXREDIRS - maximum number of redirects allowed
7

SYNOPSIS

9       #include <curl/curl.h>
10
11       CURLcode curl_easy_setopt(CURL *handle, CURLOPT_MAXREDIRS, long amount);
12

DESCRIPTION

14       Pass  a  long.  The set number will be the redirection limit amount. If
15       that many redirections have been followed, the next redirect will cause
16       an  error  (CURLE_TOO_MANY_REDIRECTS).  This option only makes sense if
17       the CURLOPT_FOLLOWLOCATION(3) is used at the same time.
18
19       Setting the limit to 0 will make libcurl refuse any redirect.
20
21       Set it to -1 for an infinite number of redirects.
22

DEFAULT

24       -1, unlimited
25

PROTOCOLS

27       HTTP(S)
28

EXAMPLE

30       curl = curl_easy_init();
31       if(curl) {
32         curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
33
34         /* enable redirect following */
35         curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
36
37         /* allow three redirects */
38         curl_easy_setopt(curl, CURLOPT_MAXREDIRS, 3L);
39
40         /* Perform the request */
41         curl_easy_perform(curl);
42       }
43

AVAILABILITY

45       Along with HTTP
46

RETURN VALUE

48       Returns CURLE_OK if HTTP is supported, and CURLE_UNKNOWN_OPTION if not.
49

SEE ALSO

51       CURLOPT_FOLLOWLOCATION(3),
52
53
54
55libcurl 7.85.0                   May 17, 2022             CURLOPT_MAXREDIRS(3)
Impressum