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