GNURLOPT_MAXREDIRS(3)
Okay bestie, welcome to the GNURLOPT_MAXREDIRS(3) manual page β we're doing redirect limits today and it's lowkey important. No cap.
π NAME π
CURLOPT_MAXREDIRS β maximum number of redirects allowed
β¨ SYNOPSIS β¨
#include <gnurl/curl.h>
CURLcode curl_easy_setopt(CURL *handle, CURLOPT_MAXREDIRS, long amount);
π DESCRIPTION π
Pass a long, bestie. The set number will be the redirection limit amount. If that many redirections have been followed, the next redirect will cause an error (CURLE_TOO_MANY_REDIRECTS). This option only makes sense if the CURLOPT_FOLLOWLOCATION(3) is used at the same time.
Setting the limit to 0 will make libcurl refuse any redirect. Periodt.
Set it to -1 for an infinite number of redirects. Iconic, but maybe chaotic π.
π DEFAULT π
-1, unlimited. The default really said "no limits, we're free" and honestly? Vibe.
π PROTOCOLS π
HTTP(S) β that's the whole menu.
π EXAMPLE π
Here's the example, bestie β copy it exactly:
curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, "http://example.com/");
/* enable redirect following */
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
/* allow three redirects */
curl_easy_setopt(curl, CURLOPT_MAXREDIRS, 3L);
/* Perform the request */
curl_easy_perform(curl);
}
π¦ AVAILABILITY π¦
Along with HTTP. That's it, that's the availability.
β RETURN VALUE β
Returns CURLE_OK if HTTP is supported, and CURLE_UNKNOWN_OPTION if not. So check your HTTP support, bestie π«Ά.
π SEE ALSO π
CURLOPT_FOLLOWLOCATION(3),β the redirect-following option that makes this whole page make sense.
Source/version and date sign-off: this page is serving libcurl 7.37.0, dated 17 Jun 2014, with manual name GNURLOPT_MAXREDIRS(3). Mwah πβ¨
π¦ where this page comes from
- nixos 26.05: libgnurl 7.72.0
- nixpkgs unstable: libgnurl 7.72.0
- Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms