CURLINFO_HTTPAUTH_USED(3)
π CURLINFO_HTTPAUTH_USED(3) β ok so which auth did we ACTUALLY use bestie
hey so this is a page from the Library Functions Manual (libcurl, the one and only π«Ά), and it's about CURLINFO_HTTPAUTH_USED β literally the "so what auth method did we end up using" getter. no cap, it's a vibe.
β¨ NAME β¨
CURLINFO_HTTPAUTH_USED β the used HTTP authentication method π
β¨ SYNOPSIS β¨
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_HTTPAUTH_USED, long *authp);
β¨ DESCRIPTION β¨
okay so picture this: you pass in a pointer to a long, and that long gets filled with a bitmask telling you which authentication method was used in the previous HTTP request. π
the meaning of the possible bits? it's all explained over in the CURLOPT_HTTPAUTH(3) option for curl_easy_setopt(3) β go read that bestie, it's the whole lore.
and here's the cute part: the returned value has zero or one bit set. so it's giving "it's either this or nothing, no messy in-betweens" π
β¨ PROTOCOLS β¨
this functionality affects http only π¦
β¨ EXAMPLE β¨
here's the whole thing, verbatim, slay:
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_HTTPAUTH, CURLAUTH_BASIC | CURLAUTH_DIGEST);
curl_easy_setopt(curl, CURLOPT_USERNAME, "shrek");
curl_easy_setopt(curl, CURLOPT_PASSWORD, "swamp");
result = curl_easy_perform(curl);
if(!result) {
long auth;
result = curl_easy_getinfo(curl, CURLINFO_HTTPAUTH_USED, &auth);
if(!result) {
if(!auth)
printf("No auth used\n");
else {
if(auth == CURLAUTH_DIGEST)
printf("Used Digest authentication\n");
else
printf("Used Basic authentication\n");
}
}
}
curl_easy_cleanup(curl);
}
}
and yes, the credentials are literally shrek / swamp. iconic. ogres have excellent security posture apparently ππ’
β¨ AVAILABILITY β¨
added in curl 8.12.0 β so if you're on something ancient, bestie, it's not you, it's the version π
β¨ RETURN VALUE β¨
curl_easy_getinfo(3) returns a CURLcode indicating success or error. that's the whole vibe check.
CURLE_OK(0) means everything was OK π- non-zero means an error occurred β check
libcurl-errors(3)for the full tea β
β¨ SEE ALSO β¨
okay that's the page!! π go forth and find out what auth your request actually used, bestie. and remember the footer lore: this was libcurl, dated 2026-10-12 β so like, future us wrote this and it still slaps πβ¨π
π¦ 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