1--- 2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3SPDX-License-Identifier: curl 4Title: CURLINFO_RESPONSE_CODE 5Section: 3 6Source: libcurl 7See-also: 8 - CURLINFO_HTTP_CONNECTCODE (3) 9 - curl_easy_getinfo (3) 10 - curl_easy_setopt (3) 11Protocol: 12 - HTTP 13 - FTP 14 - SMTP 15 - LDAP 16--- 17 18# NAME 19 20CURLINFO_RESPONSE_CODE - get the last response code 21 22# SYNOPSIS 23 24~~~c 25#include <curl/curl.h> 26 27CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_RESPONSE_CODE, long *codep); 28~~~ 29 30# DESCRIPTION 31 32Pass a pointer to a long to receive the last received HTTP, FTP, SMTP or LDAP 33(OpenLDAP only) response code. This option was previously known as 34CURLINFO_HTTP_CODE in libcurl 7.10.7 and earlier. The stored value is zero if 35no server response code has been received. 36 37Note that a proxy's CONNECT response should be read with 38CURLINFO_HTTP_CONNECTCODE(3) and not this. 39 40# EXAMPLE 41 42~~~c 43int main(void) 44{ 45 CURL *curl = curl_easy_init(); 46 if(curl) { 47 CURLcode res; 48 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); 49 res = curl_easy_perform(curl); 50 if(res == CURLE_OK) { 51 long response_code; 52 curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &response_code); 53 } 54 curl_easy_cleanup(curl); 55 } 56} 57~~~ 58 59# AVAILABILITY 60 61Added in 7.10.8. CURLINFO_HTTP_CODE was added in 7.4.1. 62Support for SMTP responses added in 7.25.0, for OpenLDAP in 7.81.0. 63 64# RETURN VALUE 65 66Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. 67