diff --git a/lib/c-hyper.c b/lib/c-hyper.c index 26635cdc1e..81e86c2adb 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))