CURLINFO_REDIRECT_COUNT(3)
π CURLINFO_REDIRECT_COUNT(3) π
okay so bestie, welcome to the CURLINFO_REDIRECT_COUNT(3) page β it's part of the Library Functions Manual, and it's literally about counting redirects. that's the whole vibe. let's get into it π
β¨ NAME β¨
CURLINFO_REDIRECT_COUNT β the number of redirects, no cap π
π¦ SYNOPSIS π¦
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_REDIRECT_COUNT,
long *countp);
π DESCRIPTION π
okay so here's the tea: you pass a pointer to a long, and it receives the total number of redirections that were actually followed. that's it. that's the whole function. iconic, honestly π
key word check π β actually followed. it's the count of redirects that genuinely got chased down, not the ones you merely dreamed about.
π§ PROTOCOLS π§
this functionality affects all supported protocols β every single one, periodt π
πΈ EXAMPLE πΈ
here's a whole little program, copy it exactly bestie, don't improvise:
int main(void)
{
CURL *curl = curl_easy_init();
if(curl) {
CURLcode result;
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
result = curl_easy_perform(curl);
if(result == CURLE_OK) {
long redirects;
curl_easy_getinfo(curl, CURLINFO_REDIRECT_COUNT, &redirects);
}
curl_easy_cleanup(curl);
}
}
see what it's doing? sets the URL, turns on CURLOPT_FOLLOWLOCATION with 1L, performs, and if the result is CURLE_OK it grabs the redirect count into redirects. she's simple, she's clean, she ate π
β AVAILABILITY β
added in curl 7.9.7 β vintage but still slaying π«Ά
π RETURN VALUE π
curl_easy_getinfo(3) returns a CURLcode indicating success or error.
CURLE_OK(0) means everything was OK π- non-zero means an error occurred β see
libcurl-errors(3)for the whole saga π
π₯ SEE ALSO π₯
go read them, they're all besties with this one π
mwah π that's the page! brought to you by libcurl, dated 2026-10-12, and it's literally called CURLINFO_REDIRECT_COUNT(3) in case you forgot already. go follow some redirects, you got this πβ¨
π¦ where this page comes from
- fedora 44: libcurl-devel 8.18.0-14.fc44 Β· curl
- fedora 44: libcurl-devel 8.18.0-14.fc44 Β· curl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms