1CURLINFO_RESPONSE_CODE(3) curl_easy_getinfo options CURLINFO_RESPONSE_CODE(3)
2
3
4
6 CURLINFO_RESPONSE_CODE - get the last response code
7
9 #include <curl/curl.h>
10
11 CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_RESPONSE_CODE, long
12 *codep);
13
15 Pass a pointer to a long to receive the last received HTTP, FTP or SMTP
16 response code. This option was previously known as CURLINFO_HTTP_CODE
17 in libcurl 7.10.7 and earlier. The stored value will be zero if no
18 server response code has been received. Note that a proxy's CONNECT
19 response should be read with CURLINFO_HTTP_CONNECTCODE(3) and not this.
20
21 Support for SMTP responses added in 7.25.0.
22
24 HTTP, FTP and SMTP
25
27 CURL *curl = curl_easy_init();
28 if(curl) {
29 CURLcode res;
30 curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
31 res = curl_easy_perform(curl);
32 if(res == CURLE_OK) {
33 long response_code;
34 curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &response_code);
35 }
36 curl_easy_cleanup(curl);
37 }
38
40 Added in 7.10.8. CURLINFO_HTTP_CODE was added in 7.4.1.
41
43 Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION
44 if not.
45
47 curl_easy_getinfo(3), curl_easy_setopt(3), CURLINFO_HTTP_CONNECTâ
48 CODE(3),
49
50
51
52libcurl 7.64.0 February 03, 2016 CURLINFO_RESPONSE_CODE(3)