GNURLINFO_...IVE_METHOD(3)

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

okay so bestie πŸ’– welcome to the GNURLINFO_...IVE_METHOD(3) page from the curl_easy_getinfo options manual β€” yes, the title is a whole mouthful, but the vibe is simple: we're getting the last used HTTP method. no cap. ✨

πŸŽ€ NAME πŸŽ€

CURLINFO_EFFECTIVE_METHOD β€” get the last used HTTP method. literally that. πŸ’…

🌸 SYNOPSIS 🌸

include this header and call this function, bestie:

       #include <gnurl/curl.h>

       CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_EFFECTIVE_METHOD,
                                  char **methodp);

πŸ¦‹ DESCRIPTION πŸ¦‹

Pass in a pointer to a char pointer and get the last used effective HTTP method. obsessed with the clarity. 🫢

In cases when you've asked libcurl to follow redirects, the method may very well not be the same method the first request would use. redirects are main character energy like that 😭

The methodp 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. do not free. periodt. πŸ’€

🌈 PROTOCOLS 🌈

HTTP(S) β€” that's it, that's the list. slay πŸ’–

πŸ”₯ EXAMPLE πŸ”₯

here's the example, copied with love and zero edits to the code:

       CURL *curl = curl_easy_init();
       if(curl) {
         CURLcode res;
         curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
         curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "data");
         curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
         res = curl_easy_perform(curl);
         if(res == CURLE_OK) {
           char *method = NULL;
           curl_easy_getinfo(curl, CURLINFO_EFFECTIVE_METHOD, &method);
           if(method)
             printf("Redirected to method: %s\n", method);
         }
         curl_easy_cleanup(curl);
       }

⭐ AVAILABILITY ⭐

Added in 7.72.0. iykyk ✨

πŸ‘‘ RETURN VALUE πŸ‘‘

Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. that's the whole return-value story, bestie. πŸŽ€

πŸ’œ SEE ALSO πŸ’œ

go read those too, they're part of the friend group. 🫢


okay bye bestie πŸ’– this page is from libcurl 7.72.0, dated 28 Aug 2015, and it's literally GNURLINFO_...IVE_METHOD(3). slay and stay hydrated. πŸ“

πŸ“¦ where this page comes from