CURLINFO_RESPONSE_CODE.3 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. .\" generated by cd2nroff 0.1 from CURLINFO_RESPONSE_CODE.md
  2. .TH CURLINFO_RESPONSE_CODE 3 "2025-01-17" libcurl
  3. .SH NAME
  4. CURLINFO_RESPONSE_CODE \- get the last response code
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_RESPONSE_CODE, long *codep);
  9. .fi
  10. .SH DESCRIPTION
  11. Pass a pointer to a long to receive the last received HTTP, FTP, SMTP or LDAP
  12. (OpenLDAP only) response code. This option was previously known as
  13. CURLINFO_HTTP_CODE in libcurl 7.10.7 and earlier. The stored value is zero if
  14. no server response code has been received.
  15. Note that a proxy\(aqs CONNECT response should be read with
  16. \fICURLINFO_HTTP_CONNECTCODE(3)\fP and not this.
  17. .SH PROTOCOLS
  18. This functionality affects ftp, http, ldap and smtp
  19. .SH EXAMPLE
  20. .nf
  21. int main(void)
  22. {
  23. CURL *curl = curl_easy_init();
  24. if(curl) {
  25. CURLcode res;
  26. curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
  27. res = curl_easy_perform(curl);
  28. if(res == CURLE_OK) {
  29. long response_code;
  30. curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &response_code);
  31. }
  32. curl_easy_cleanup(curl);
  33. }
  34. }
  35. .fi
  36. .SH NOTES
  37. The former name, CURLINFO_HTTP_CODE, was added in 7.4.1. Support for SMTP
  38. responses added in 7.25.0, for OpenLDAP in 7.81.0.
  39. .SH AVAILABILITY
  40. Added in curl 7.10.8
  41. .SH RETURN VALUE
  42. Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
  43. .SH SEE ALSO
  44. .BR CURLINFO_HTTP_CONNECTCODE (3),
  45. .BR curl_easy_getinfo (3),
  46. .BR curl_easy_setopt (3)