CURLINFO_HTTP_VERSION.3 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. .\" generated by cd2nroff 0.1 from CURLINFO_HTTP_VERSION.md
  2. .TH CURLINFO_HTTP_VERSION 3 "2025-01-17" libcurl
  3. .SH NAME
  4. CURLINFO_HTTP_VERSION \- get the http version used in the connection
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_HTTP_VERSION, long *p);
  9. .fi
  10. .SH DESCRIPTION
  11. Pass a pointer to a long to receive the version used in the last http
  12. connection done using this handle. The returned value is
  13. CURL_HTTP_VERSION_1_0, CURL_HTTP_VERSION_1_1, CURL_HTTP_VERSION_2_0,
  14. CURL_HTTP_VERSION_3 or 0 if the version cannot be determined.
  15. .SH PROTOCOLS
  16. This functionality affects http only
  17. .SH EXAMPLE
  18. .nf
  19. int main(void)
  20. {
  21. CURL *curl = curl_easy_init();
  22. if(curl) {
  23. CURLcode res;
  24. curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
  25. res = curl_easy_perform(curl);
  26. if(res == CURLE_OK) {
  27. long http_version;
  28. curl_easy_getinfo(curl, CURLINFO_HTTP_VERSION, &http_version);
  29. }
  30. curl_easy_cleanup(curl);
  31. }
  32. }
  33. .fi
  34. .SH AVAILABILITY
  35. Added in curl 7.50.0
  36. .SH RETURN VALUE
  37. Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
  38. .SH SEE ALSO
  39. .BR CURLINFO_RESPONSE_CODE (3),
  40. .BR curl_easy_getinfo (3),
  41. .BR curl_easy_setopt (3)