CURLINFO_EFFECTIVE_METHOD(3)
β¨ CURLINFO_EFFECTIVE_METHOD β¨
okay bestie, so this is a page from the Library Functions Manual (iconic, we love a libcurl moment) and it's all about CURLINFO_EFFECTIVE_METHOD β literally the last HTTP request method that got used. no cap, that's the whole vibe. π
πΈ NAME πΈ
CURLINFO_EFFECTIVE_METHOD β the last used HTTP request method π
π¦ SYNOPSIS π¦
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_EFFECTIVE_METHOD,
char **methodp);
π DESCRIPTION π
so you pass in a pointer to a char pointer, right? and you get back the last used effective HTTP method. that's it, that's the tea. β¨
and here's the sneaky part: if you've told libcurl to follow redirects, the method you end up with may not be the same method the first request would use. it's giving plot twist. π so don't assume, okay?
the methodp pointer is either NULL or it points to private memory β and you must not free it. nope. not you, not ever. π that memory gets freed automatically when you call curl_easy_cleanup(3) on the corresponding curl handle. libcurl's got it handled, trust. π«Ά
π PROTOCOLS π
this functionality affects http only. that's the whole list. http bestie, nobody else. π
β EXAMPLE β
here's the moment you've all been waiting for, the code, look at her go π
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_POSTFIELDS, "data");
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
result = curl_easy_perform(curl);
if(result == 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);
}
}
like, she sets the URL, sets CURLOPT_POSTFIELDS to "data", turns on CURLOPT_FOLLOWLOCATION with 1L, runs it, and if result == CURLE_OK she grabs the method and prints "Redirected to method: %s\n". then cleanup. main character energy fr fr. π₯
πΈ AVAILABILITY πΈ
added in curl 7.72.0. so if you're on anything older, sorry babe, she's not there yet. π
π§ RETURN VALUE π§
curl_easy_getinfo(3) returns a CURLcode indicating success or error.
CURLE_OK(0) means everything was OK π- anything non-zero means an error occurred β go check
libcurl-errors(3)and figure out what went down π
π₯ SEE ALSO π₯
go read them, iykyk πβ¨
and that's the page!! this lil gem comes to you from libcurl, dated 2026-10-12, living under the title CURLINFO_EFFECTIVE_METHOD(3) β ok bye bestie, go get that method π
ππ¦
π¦ where this page comes from
- fedora 44: libcurl-devel 8.18.0-14.fc44 Β· curl
- fedora 44: libcurl-devel 8.18.0-14.fc44 Β· curl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms