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 16Added-in: 7.10.8 17--- 18 19# NAME 20 21CURLINFO_RESPONSE_CODE - get the last response code 22 23# SYNOPSIS 24 25~~~c 26#include <curl/curl.h> 27 28CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_RESPONSE_CODE, long *codep); 29~~~ 30 31# DESCRIPTION 32 33Pass a pointer to a long to receive the last received HTTP, FTP, SMTP or LDAP 34(OpenLDAP only) response code. This option was previously known as 35CURLINFO_HTTP_CODE in libcurl 7.10.7 and earlier. The stored value is zero if 36no server response code has been received. 37 38Note that a proxy's CONNECT response should be read with 39CURLINFO_HTTP_CONNECTCODE(3) and not this. 40 41# %PROTOCOLS% 42 43# EXAMPLE 44 45~~~c 46int main(void) 47{ 48 CURL *curl = curl_easy_init(); 49 if(curl) { 50 CURLcode res; 51 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); 52 res = curl_easy_perform(curl); 53 if(res == CURLE_OK) { 54 long response_code; 55 curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &response_code); 56 } 57 curl_easy_cleanup(curl); 58 } 59} 60~~~ 61 62# NOTES 63 64The former name, CURLINFO_HTTP_CODE, was added in 7.4.1. Support for SMTP 65responses added in 7.25.0, for OpenLDAP in 7.81.0. 66 67# %AVAILABILITY% 68 69# RETURN VALUE 70 71Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. 72