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. This is not sensible to do
17       unless you have a good reason. You have to set this option if you  want
18       to use libcurl's HTTP/2 support.
19
20       Note that the HTTP version is just a request. libcurl will still prior‐
21       itize to re-use an existing connection so it might then re-use  a  con‐
22       nection using a HTTP version you haven't asked for.
23
24
25       CURL_HTTP_VERSION_NONE
26              We  don't care about what version the library uses. libcurl will
27              use whatever it thinks fit.
28
29       CURL_HTTP_VERSION_1_0
30              Enforce HTTP 1.0 requests.
31
32       CURL_HTTP_VERSION_1_1
33              Enforce HTTP 1.1 requests.
34
35       CURL_HTTP_VERSION_2_0
36              Attempt HTTP 2 requests. libcurl will fall back to HTTP  1.1  if
37              HTTP 2 can't be negotiated with the server. (Added in 7.33.0)
38
39              The  alias  CURL_HTTP_VERSION_2  was  added  in 7.43.0 to better
40              reflect the actual protocol name.
41
42       CURL_HTTP_VERSION_2TLS
43              Attempt HTTP 2 over TLS (HTTPS) only. libcurl will fall back  to
44              HTTP  1.1  if  HTTP 2 can't be negotiated with the HTTPS server.
45              For clear text HTTP servers, libcurl will  use  1.1.  (Added  in
46              7.47.0)
47
48       CURL_HTTP_VERSION_2_PRIOR_KNOWLEDGE
49              Issue  non-TLS  HTTP  requests  using  HTTP/2  without  HTTP/1.1
50              Upgrade. It requires prior knowledge that  the  server  supports
51              HTTP/2  straight  away.  HTTPS requests will still do HTTP/2 the
52              standard way with negotiated protocol version in the  TLS  hand‐
53              shake. (Added in 7.49.0)
54

DEFAULT

56       CURL_HTTP_VERSION_NONE
57

PROTOCOLS

59       HTTP
60

EXAMPLE

62       CURL *curl = curl_easy_init();
63       if(curl) {
64         CURLcode ret;
65         curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
66         curl_easy_setopt(curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2TLS);
67         ret = curl_easy_perform(curl);
68         if(ret == CURLE_HTTP_RETURNED_ERROR) {
69           /* an HTTP response error problem */
70         }
71       }
72

AVAILABILITY

74       Along with HTTP
75

RETURN VALUE

77       Returns CURLE_OK if HTTP is supported, and CURLE_UNKNOWN_OPTION if not.
78

SEE ALSO

80       CURLOPT_SSLVERSION(3), CURLOPT_HTTP200ALIASES(3),
81
82
83
84libcurl 7.61.1                  April 17, 2018         CURLOPT_HTTP_VERSION(3)
Impressum