GNURLINFO_...IVE_METHOD(3)
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
- nixos 26.05: libgnurl 7.72.0
- nixpkgs unstable: libgnurl 7.72.0
- Copyright (C) 1998 - 2020, 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