GNURLINFO_EFFECTIVE_URL(3)
π NAME π
okay so bestie, this page is GNURLINFO_EFFECTIVE_URL(3), and it lives in the curl_easy_getinfo options manual β cute lil' corner of the docs. CURLINFO_EFFECTIVE_URL is the constant for getting the last used URL. That's the whole main-character job. β¨
π SYNOPSIS π
#include <gnurl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_EFFECTIVE_URL, char
**urlp);
π DESCRIPTION π
Pass in a pointer to a char pointer, and you get the last used effective URL. Simple as that, no cap.
In cases when you've asked libcurl to follow redirects, it may very well not be the same value you set with CURLOPT_URL(3). Redirects said "new URL, who dis?" and honestly they ate. πββοΈ
π¨ bestie, listen: theurlppointer will beNULLor pointing to private memory you MUST NOT free β it gets freed when you callcurl_easy_cleanup(3)on the correspondingCURLhandle. Do not touch that memory with your own cleanup. Periodt. π
π PROTOCOLS π
HTTP(S) β that's the protocol vibe here. π¦
π EXAMPLE π
CURL *curl = curl_easy_init();
if(curl) {
CURLcode res;
curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
res = curl_easy_perform(curl);
if(res == 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);
}
π¦ AVAILABILITY π¦
Added in 7.4. She's been iconic for a minute. π
π₯ RETURN VALUE π₯
Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. That's it, that's the vibe check. β
π SEE ALSO π
kisses, this page is from libcurl 7.44.0, dated 28 Aug 2015 β mwah ππ
π¦ where this page comes from
- nixos 26.05: libgnurl 7.72.0
- nixpkgs unstable: libgnurl 7.72.0
- Copyright (C) 1998 - 2017, 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