1--- 2c: Copyright (C) Daniel Stenberg, <daniel.se>, et al. 3SPDX-License-Identifier: curl 4Title: CURLINFO_HTTP_VERSION 5Section: 3 6Source: libcurl 7See-also: 8 - CURLINFO_RESPONSE_CODE (3) 9 - curl_easy_getinfo (3) 10 - curl_easy_setopt (3) 11--- 12 13# NAME 14 15CURLINFO_HTTP_VERSION - get the http version used in the connection 16 17# SYNOPSIS 18 19~~~c 20#include <curl/curl.h> 21 22CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_HTTP_VERSION, long *p); 23~~~ 24 25# DESCRIPTION 26 27Pass a pointer to a long to receive the version used in the last http 28connection done using this handle. The returned value is 29CURL_HTTP_VERSION_1_0, CURL_HTTP_VERSION_1_1, CURL_HTTP_VERSION_2_0, 30CURL_HTTP_VERSION_3 or 0 if the version cannot be determined. 31 32# PROTOCOLS 33 34HTTP 35 36# EXAMPLE 37 38~~~c 39int main(void) 40{ 41 CURL *curl = curl_easy_init(); 42 if(curl) { 43 CURLcode res; 44 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); 45 res = curl_easy_perform(curl); 46 if(res == CURLE_OK) { 47 long http_version; 48 curl_easy_getinfo(curl, CURLINFO_HTTP_VERSION, &http_version); 49 } 50 curl_easy_cleanup(curl); 51 } 52} 53~~~ 54 55# AVAILABILITY 56 57Added in 7.50.0 58 59# RETURN VALUE 60 61Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. 62