CURLINFO_HTTP_VERSION − HTTP version used in the transfer
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_HTTP_VERSION, long *p);
Pass a pointer to a long to receive the version used in the last http transfer done using this handle. The returned value is CURL_HTTP_VERSION_1_0, CURL_HTTP_VERSION_1_1, CURL_HTTP_VERSION_2_0, CURL_HTTP_VERSION_3 or 0 if the version cannot be determined.
This functionality affects http only
int main(void)
{
CURL *curl = curl_easy_init();
if(curl) {
CURLcode result;
curl_easy_setopt(curl, CURLOPT_URL,
"https://example.com");
result = curl_easy_perform(curl);
if(result == CURLE_OK) {
long http_version;
curl_easy_getinfo(curl, CURLINFO_HTTP_VERSION,
&http_version);
}
curl_easy_cleanup(curl);
}
}
Added in curl 7.50.0
curl_easy_getinfo(3) returns a CURLcode indicating success or error.
CURLE_OK (0) means everything was OK, non−zero means an error occurred, see libcurl−errors(3).
CURLINFO_RESPONSE_CODE(3), curl_easy_getinfo(3), curl_easy_setopt(3)