diff options
author | Daniel Stenberg <daniel@haxx.se> | 2015-12-13 09:23:36 +0100 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2015-12-13 09:24:51 +0100 |
commit | 4bcc532de5b639ace6f96f0a30524a08861843b1 (patch) | |
tree | 8d808958c1a58f54b1d29ca68dbe9baaef752d57 /lib/http.c | |
parent | 7f683b0ea87ed158eb4bd22cdd1f26eb901a97d0 (diff) |
http: add libcurl option to allow HTTP/2 for HTTPS only
... and stick to 1.1 for HTTP. This is in line with what browsers do and
should have very little risk.
Diffstat (limited to 'lib/http.c')
-rw-r--r-- | lib/http.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/lib/http.c b/lib/http.c index 3c9fde54a..b77003fe7 100644 --- a/lib/http.c +++ b/lib/http.c @@ -1539,11 +1539,13 @@ CURLcode Curl_http_done(struct connectdata *conn, static bool use_http_1_1plus(const struct SessionHandle *data, const struct connectdata *conn) { - return ((data->set.httpversion >= CURL_HTTP_VERSION_1_1) || - ((data->set.httpversion != CURL_HTTP_VERSION_1_0) && - ((conn->httpversion == 11) || - ((conn->httpversion != 10) && - (data->state.httpversion != 10))))) ? TRUE : FALSE; + if((data->state.httpversion == 10) || (conn->httpversion == 10)) + return FALSE; + if((data->set.httpversion == CURL_HTTP_VERSION_1_0) && + (conn->httpversion <= 10)) + return FALSE; + return ((data->set.httpversion == CURL_HTTP_VERSION_NONE) || + (data->set.httpversion >= CURL_HTTP_VERSION_1_1)); } /* check and possibly add an Expect: header */ @@ -1785,7 +1787,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done) if(conn->httpversion < 20) { /* unless the connection is re-used and already http2 */ switch(conn->negnpn) { - case CURL_HTTP_VERSION_2_0: + case CURL_HTTP_VERSION_2: conn->httpversion = 20; /* we know we're on HTTP/2 now */ result = Curl_http2_init(conn); if(result) @@ -2338,7 +2340,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done) if(!(conn->handler->flags&PROTOPT_SSL) && conn->httpversion != 20 && - (data->set.httpversion == CURL_HTTP_VERSION_2_0)) { + (data->set.httpversion == CURL_HTTP_VERSION_2)) { /* append HTTP2 upgrade magic stuff to the HTTP request if it isn't done over SSL */ result = Curl_http2_request_upgrade(req_buffer, conn); |