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

NAME

6       CURLOPT_HTTP_VERSION - specify HTTP protocol version to use
7

SYNOPSIS

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

DESCRIPTION

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

DEFAULT

64       Since curl 7.62.0: CURL_HTTP_VERSION_2TLS
65
66       Before that: CURL_HTTP_VERSION_1_1
67

PROTOCOLS

69       HTTP
70

EXAMPLE

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

AVAILABILITY

84       Along with HTTP
85

RETURN VALUE

87       Returns CURLE_OK if HTTP is supported, and CURLE_UNKNOWN_OPTION if not.
88

SEE ALSO

90       CURLOPT_SSLVERSION(3),  CURLOPT_HTTP200ALIASES(3),   CURLOPT_HTTP09_AL‐
91       LOWED(3), CURLOPT_ALTSVC(3)
92
93
94
95libcurl 7.76.1                 November 04, 2020       CURLOPT_HTTP_VERSION(3)
Impressum