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's CONNECT response should be read with CURLINFO_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