CURLINFO_RESPONSE_CODE(3)
πΈ NAME πΈ
okay so this is the CURLINFO_RESPONSE_CODE(3) page from the Library Functions Manual, and it's literally about grabbing the last response code, bestie. no cap. π«Ά
CURLINFO_RESPONSE_CODE β last response code π
β¨ SYNOPSIS β¨
#include <curl/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, SMTP or LDAP (OpenLDAP only) response code. iconic. β¨
fun fact: this option was previously known as CURLINFO_HTTP_CODE in libcurl 7.10.7 and earlier. the way that history is still living with us π
the stored value is zero if no server response code has been received. good to know, fr fr.
β οΈ note that a proxy'sCONNECTresponse should be read withCURLINFO_HTTP_CONNECTCODE(3)and not this. not this one, bestie. π
π¦ PROTOCOLS π¦
this functionality affects ftp, http, ldap and smtp π
π EXAMPLE π
int main(void)
{
CURL *curl = curl_easy_init();
if(curl) {
CURLcode result;
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
result = curl_easy_perform(curl);
if(result == CURLE_OK) {
long response_code;
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &response_code);
}
curl_easy_cleanup(curl);
}
}
π§ NOTES π§
the former name, CURLINFO_HTTP_CODE, was added in 7.4.1. support for SMTP responses added in 7.25.0, for OpenLDAP in 7.81.0. periodt. π
β AVAILABILITY β
added in curl 7.10.8 π
π RETURN VALUE π
curl_easy_getinfo(3) returns a CURLcode indicating success or error. simple enough, bestie.
CURLE_OK (0) means everything was OK, non-zero means an error occurred, see libcurl-errors(3). π«Ά
π₯ SEE ALSO π₯
mwah π β this page is brought to you by libcurl, dated 2026-10-12, on the CURLINFO_RESPONSE_CODE(3) manual page. periodt. π
π¦ 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