CURLOPT_MAXREDIRS.3 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. .\" generated by cd2nroff 0.1 from CURLOPT_MAXREDIRS.md
  2. .TH CURLOPT_MAXREDIRS 3 "2025-01-17" libcurl
  3. .SH NAME
  4. CURLOPT_MAXREDIRS \- maximum number of redirects allowed
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_MAXREDIRS, long amount);
  9. .fi
  10. .SH DESCRIPTION
  11. Pass a long. The set number is the redirection limit \fIamount\fP. If that
  12. many redirections have been followed, the next redirect triggers the error
  13. (\fICURLE_TOO_MANY_REDIRECTS\fP). This option only makes sense if the
  14. \fICURLOPT_FOLLOWLOCATION(3)\fP is used at the same time.
  15. Setting the limit to 0 makes libcurl refuse any redirect.
  16. Set it to \-1 for an infinite number of redirects. This allows your application
  17. to get stuck in never\-ending redirect loops.
  18. .SH DEFAULT
  19. 30 (since 8.3.0), it was previously unlimited.
  20. .SH PROTOCOLS
  21. This functionality affects http only
  22. .SH EXAMPLE
  23. .nf
  24. int main(void)
  25. {
  26. CURL *curl = curl_easy_init();
  27. if(curl) {
  28. curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
  29. /* enable redirect following */
  30. curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
  31. /* allow three redirects */
  32. curl_easy_setopt(curl, CURLOPT_MAXREDIRS, 3L);
  33. /* Perform the request */
  34. curl_easy_perform(curl);
  35. }
  36. }
  37. .fi
  38. .SH AVAILABILITY
  39. Added in curl 7.5
  40. .SH RETURN VALUE
  41. Returns CURLE_OK if HTTP is supported, and CURLE_UNKNOWN_OPTION if not.
  42. .SH SEE ALSO
  43. .BR CURLINFO_REDIRECT_COUNT (3),
  44. .BR CURLINFO_REDIRECT_URL (3),
  45. .BR CURLOPT_FOLLOWLOCATION (3)