1CURLOPT_HTTP_VERSION(3)    curl_easy_setopt options    CURLOPT_HTTP_VERSION(3)
2
3
4

NAME

6       CURLOPT_HTTP_VERSION - HTTP protocol version to use
7

SYNOPSIS

9       #include <curl/curl.h>
10
11       CURLcode curl_easy_setopt(CURL *handle, CURLOPT_HTTP_VERSION, long version);
12

DESCRIPTION

14       Pass version a long, set to one of the values described below. They ask
15       libcurl to use the specific HTTP versions.
16
17       Note that the HTTP version is just a request. libcurl will still prior‐
18       itize  to  re-use an existing connection so it might then re-use a con‐
19       nection using a HTTP version you have not asked for.
20
21
22       CURL_HTTP_VERSION_NONE
23              We do not care about what version the library uses. libcurl will
24              use whatever it thinks fit.
25
26       CURL_HTTP_VERSION_1_0
27              Enforce HTTP 1.0 requests.
28
29       CURL_HTTP_VERSION_1_1
30              Enforce HTTP 1.1 requests.
31
32       CURL_HTTP_VERSION_2_0
33              Attempt  HTTP  2 requests. libcurl will fall back to HTTP 1.1 if
34              HTTP 2 cannot be negotiated with the server. (Added in 7.33.0)
35
36              When libcurl uses HTTP/2 over HTTPS, it does not  itself  insist
37              on  TLS 1.2 or higher even though that is required by the speci‐
38              fication. A user can add  this  version  requirement  with  CUR‐
39              LOPT_SSLVERSION(3).
40
41              The  alias CURL_HTTP_VERSION_2 was added in 7.43.0 to better re‐
42              flect the actual protocol name.
43
44       CURL_HTTP_VERSION_2TLS
45              Attempt HTTP 2 over TLS (HTTPS) only. libcurl will fall back  to
46              HTTP  1.1  if HTTP 2 cannot be negotiated with the HTTPS server.
47              For clear text HTTP servers, libcurl will  use  1.1.  (Added  in
48              7.47.0)
49
50       CURL_HTTP_VERSION_2_PRIOR_KNOWLEDGE
51              Issue  non-TLS  HTTP  requests using HTTP/2 without HTTP/1.1 Up‐
52              grade. It requires prior  knowledge  that  the  server  supports
53              HTTP/2  straight  away.  HTTPS requests will still do HTTP/2 the
54              standard way with negotiated protocol version in the  TLS  hand‐
55              shake. (Added in 7.49.0)
56
57       CURL_HTTP_VERSION_3
58              (Added  in  7.66.0) Setting this value will make libcurl attempt
59              to use HTTP/3 directly to server given in  the  URL.  Note  that
60              this  cannot gracefully downgrade to earlier HTTP version if the
61              server does not support HTTP/3.
62
63              For more reliably upgrading to HTTP/3, set the preferred version
64              to  something  lower and let the server announce its HTTP/3 sup‐
65              port via Alt-Svc:. See CURLOPT_ALTSVC(3).
66

DEFAULT

68       Since curl 7.62.0: CURL_HTTP_VERSION_2TLS
69
70       Before that: CURL_HTTP_VERSION_1_1
71

PROTOCOLS

73       HTTP
74

EXAMPLE

76       CURL *curl = curl_easy_init();
77       if(curl) {
78         CURLcode ret;
79         curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
80         curl_easy_setopt(curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2TLS);
81         ret = curl_easy_perform(curl);
82         if(ret == CURLE_HTTP_RETURNED_ERROR) {
83           /* an HTTP response error problem */
84         }
85       }
86

AVAILABILITY

88       Along with HTTP
89

RETURN VALUE

91       Returns CURLE_OK if HTTP is supported, and CURLE_UNKNOWN_OPTION if not.
92

SEE ALSO

94       CURLOPT_SSLVERSION(3),  CURLOPT_HTTP200ALIASES(3),   CURLOPT_HTTP09_AL‐
95       LOWED(3), CURLOPT_ALTSVC(3)
96
97
98
99libcurl 7.85.0                   May 17, 2022          CURLOPT_HTTP_VERSION(3)
Impressum