CURLINFO_EFFECTIVE_URL(3)
π CURLINFO_EFFECTIVE_URL π
okay so real talk bestie, this page is from the Library Functions Manual and it's literally all about CURLINFO_EFFECTIVE_URL β the last used URL, no cap. let me break it down for you π«Ά
β¨ NAME β¨
CURLINFO_EFFECTIVE_URL β last used URL π
π SYNOPSIS π
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_EFFECTIVE_URL, char **urlp);
πΈ DESCRIPTION πΈ
so you pass in a pointer to a char pointer and you get back the last used effective URL. that's the whole vibe π
here's the tea though: in cases when you have asked libcurl to follow redirects, it may not be the same value you set with CURLOPT_URL(3) β like, the URL you started with and the URL it ended up at are two different girls, iykyk π
also important: the urlp pointer is NULL or points to private memory. you must not free it π that memory gets freed automatically when you call curl_easy_cleanup(3) on the corresponding curl handle. so like, hands off, it's not yours π
π¦ PROTOCOLS π¦
this functionality affects http only
π EXAMPLE π
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) {
char *url = NULL;
curl_easy_getinfo(curl, CURLINFO_EFFECTIVE_URL, &url);
if(url)
printf("Redirect to: %s\n", url);
}
curl_easy_cleanup(curl);
}
}
look at her go π§ she sets the URL, sets CURLOPT_FOLLOWLOCATION to 1L, performs, and then prints where she actually landed. main character energy fr fr β
π AVAILABILITY π
Added in curl 7.4 β vintage icon behavior, we love a classic π
π₯ RETURN VALUE π₯
curl_easy_getinfo(3) returns a CURLcode indicating success or error.
CURLE_OK (0) means everything was OK β slay β
non-zero means an error occurred, see libcurl-errors(3) π
π SEE ALSO π
aaaand that's the whole page bestie πΈ it's giving libcurl, dated 2026-10-12, and honestly? iconic. go get those redirect URLs πβ¨π¦
π¦ 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