GNURLINFO_RESPONSE_CODE(3)
okay bestie, welcome to GNURLINFO_RESPONSE_CODE(3) β straight from the curl_easy_getinfo options manual, and it's giving βtiny but powerfulβ energy. π
β¨
NAME π
CURLINFO_RESPONSE_CODE β grab the last response code. no cap, that's the whole vibe. π«Ά
SYNOPSIS π
#include <gnurl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_RESPONSE_CODE, long *codep);
DESCRIPTION π
okay so you pass a pointer to a long, and it receives the last received HTTP, FTP or SMTP response code. that's the main character move. π₯
fun lil history fact: this option was previously known as CURLINFO_HTTP_CODE in libcurl 7.10.7 and earlier. the stored value will be zero if no server response code has been received. literally zero, bestie. π
β οΈ important side note: a proxy'sCONNECTresponse should be read withCURLINFO_HTTP_CONNECTCODE(3)and not this. iykyk. π«‘
Support for SMTP responses added in 7.25.0. slay. π
PROTOCOLS π
HTTP, FTP and SMTP β that's the lineup. π«
EXAMPLE π
here's the snippet, copied exactly because we do not mess with code in this group chat: π§
CURL *curl = curl_easy_init();
if(curl) {
CURLcode res;
curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
res = curl_easy_perform(curl);
if(res == CURLE_OK) {
long response_code;
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &response_code);
}
curl_easy_cleanup(curl);
}
AVAILABILITY π¦
Added in 7.10.8. CURLINFO_HTTP_CODE was added in 7.4.1. vintage but still iconic. π
RETURN VALUE π
Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. simple, clean, periodt. π
SEE ALSO π
mwah π this cutie page comes from libcurl 7.44.0, dated 28 Aug 2015. bye bestie, go get those response codes! ππβ¨
π¦ 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