diff options
author | Daniel Stenberg <daniel@haxx.se> | 2021-10-08 11:33:50 +0200 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2021-10-08 15:14:29 +0200 |
commit | 4e0c28923a5becacecc4a0e9a8f9e8fc2a3ac701 (patch) | |
tree | 25e01fbfc2a2d4d80b5f508b05444add61e06e0a | |
parent | 9597d2def7435bf31966d3179ff37d95c613e9b2 (diff) | |
download | curl-4e0c28923a5becacecc4a0e9a8f9e8fc2a3ac701.tar.gz |
c-hyper: use hyper_request_set_uri_parts to make h2 better
and make sure to not send Host: over h2.
Fixes #7679
Reported-by: David Cook
Closes #7827
-rw-r--r-- | lib/c-hyper.c | 37 |
1 files changed, 31 insertions, 6 deletions
diff --git a/lib/c-hyper.c b/lib/c-hyper.c index 26635cdc1..81e86c2ad 100644 --- a/lib/c-hyper.c +++ b/lib/c-hyper.c @@ -584,9 +584,22 @@ static CURLcode request_target(struct Curl_easy *data, if(result) return result; - if(hyper_request_set_uri(req, (uint8_t *)Curl_dyn_uptr(&r), - Curl_dyn_len(&r))) { - failf(data, "error setting path"); + if(h2 && hyper_request_set_uri_parts(req, + /* scheme */ + (uint8_t *)data->state.up.scheme, + strlen(data->state.up.scheme), + /* authority */ + (uint8_t *)conn->host.name, + strlen(conn->host.name), + /* path_and_query */ + (uint8_t *)Curl_dyn_uptr(&r), + Curl_dyn_len(&r))) { + failf(data, "error setting uri parts to hyper"); + result = CURLE_OUT_OF_MEMORY; + } + else if(!h2 && hyper_request_set_uri(req, (uint8_t *)Curl_dyn_uptr(&r), + Curl_dyn_len(&r))) { + failf(data, "error setting uri to hyper"); result = CURLE_OUT_OF_MEMORY; } else @@ -939,9 +952,21 @@ CURLcode Curl_http(struct Curl_easy *data, bool *done) if(result) return result; - if(data->state.aptr.host && - Curl_hyper_header(data, headers, data->state.aptr.host)) - goto error; + if(!h2) { + if(data->state.aptr.host && + Curl_hyper_header(data, headers, data->state.aptr.host)) + goto error; + } + else { + /* For HTTP/2, we show the Host: header as if we sent it, to make it look + like for HTTP/1 but it isn't actually sent since :authority is then + used. */ + if(Curl_debug(data, CURLINFO_HEADER_OUT, data->state.aptr.host, + strlen(data->state.aptr.host))) { + result = CURLE_ABORTED_BY_CALLBACK; + goto error; + } + } if(data->state.aptr.proxyuserpwd && Curl_hyper_header(data, headers, data->state.aptr.proxyuserpwd)) |