GNURLINFO_EFFECTIVE_URL(3)

πŸ“¦ version 7.72.0, in nixos 26.05, nixpkgs unstable

πŸ’– 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: the urlp pointer will be NULL or pointing to private memory you MUST NOT free β€” it gets freed when you call curl_easy_cleanup(3) on the corresponding CURL handle. 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