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       Since curl 7.62.0: CURL_HTTP_VERSION_2TLS
57
58       Before that: CURL_HTTP_VERSION_1_1
59

PROTOCOLS

61       HTTP
62

EXAMPLE

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

AVAILABILITY

76       Along with HTTP
77

RETURN VALUE

79       Returns CURLE_OK if HTTP is supported, and CURLE_UNKNOWN_OPTION if not.
80

SEE ALSO

82       CURLOPT_SSLVERSION(3),          CURLOPT_HTTP200ALIASES(3),         CUR‐
83       LOPT_HTTP09_ALLOWED(3),
84
85
86
87libcurl 7.64.0                 December 17, 2018       CURLOPT_HTTP_VERSION(3)
Impressum