http: strip default port from URL sent to proxy

To make sure the Host: header and the URL provide the same authority
portion when sent to the proxy, strip the default port number from the
URL if one was provided.

Reported-by: Michael Brown
Fixes #6769
Closes #6778
This commit is contained in:
Daniel Stenberg 2021-03-23 00:24:59 +01:00
parent 45d1e24b74
commit 3bbf62b5a4
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2
2 changed files with 2 additions and 2 deletions

View File

@ -2189,7 +2189,7 @@ CURLcode Curl_http_target(struct Curl_easy *data,
/* Extract the URL to use in the request. Store in STRING_TEMP_URL for
clean-up reasons if the function returns before the free() further
down. */
uc = curl_url_get(h, CURLUPART_URL, &url, 0);
uc = curl_url_get(h, CURLUPART_URL, &url, CURLU_NO_DEFAULT_PORT);
if(uc) {
curl_url_cleanup(h);
return CURLE_OUT_OF_MEMORY;

View File

@ -43,7 +43,7 @@ proxy
<verify>
<protocol>
GET http://www.example.com:80/ HTTP/1.1
GET http://www.example.com/ HTTP/1.1
Host: www.example.com
Accept: */*
Proxy-Connection: Keep-Alive