1CURLINFO_RESPONSE_CODE(3)  curl_easy_getinfo options CURLINFO_RESPONSE_CODE(3)
2
3
4

NAME

6       CURLINFO_RESPONSE_CODE - get the last response code
7

SYNOPSIS

9       #include <curl/curl.h>
10
11       CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_RESPONSE_CODE, long *codep);
12

DESCRIPTION

14       Pass  a  pointer to a long to receive the last received HTTP, FTP, SMTP
15       or LDAP (OpenLDAP only) response code. This option was previously known
16       as  CURLINFO_HTTP_CODE in libcurl 7.10.7 and earlier.  The stored value
17       will be zero if no server response code has been received.  Note that a
18       proxy's  CONNECT  response  should  be read with CURLINFO_HTTP_CONNECT‐
19       CODE(3) and not this.
20

PROTOCOLS

22       HTTP, FTP, SMTP and LDAP
23

EXAMPLE

25       CURL *curl = curl_easy_init();
26       if(curl) {
27         CURLcode res;
28         curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
29         res = curl_easy_perform(curl);
30         if(res == CURLE_OK) {
31           long response_code;
32           curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &response_code);
33         }
34         curl_easy_cleanup(curl);
35       }
36

AVAILABILITY

38       Added in 7.10.8. CURLINFO_HTTP_CODE was added in  7.4.1.   Support  for
39       SMTP responses added in 7.25.0, for OpenLDAP in 7.81.0.
40

RETURN VALUE

42       Returns  CURLE_OK  if the option is supported, and CURLE_UNKNOWN_OPTION
43       if not.
44

SEE ALSO

46       curl_easy_getinfo(3),    curl_easy_setopt(3),    CURLINFO_HTTP_CONNECT‐
47       CODE(3),
48
49
50
51libcurl 8.0.1                  January 02, 2023      CURLINFO_RESPONSE_CODE(3)
Impressum