aboutsummaryrefslogtreecommitdiffstats
path: root/lib/inets/src/http_client/httpc_response.erl
diff options
context:
space:
mode:
authorBram Verburg <[email protected]>2017-03-17 10:35:49 +0200
committerBram Verburg <[email protected]>2017-03-17 10:35:49 +0200
commita13e73d70d2af0a686701a3c8b16b82b664abd19 (patch)
treeeb65fc99bdcef423cbdb41c818d6fccfd52ccc47 /lib/inets/src/http_client/httpc_response.erl
parenta748cafdc7063d9f181ba12088db6458793ced2f (diff)
downloadotp-a13e73d70d2af0a686701a3c8b16b82b664abd19.tar.gz
otp-a13e73d70d2af0a686701a3c8b16b82b664abd19.tar.bz2
otp-a13e73d70d2af0a686701a3c8b16b82b664abd19.zip
Omit port from Host header on redirect to well-known port
ERL-316, as part of 19.3, adds the port number to the Host header upon automatic redirection. The port number is included even if it is a well-known port (80, 443). This is different from the behaviour of most HTTP clients, as well as httpc's own for new requests. The added port number can lead to problems such as this one, where the request signature assumes the client will not send the :443 suffix on redirection to an https URL: https://github.com/nerves-project/nerves/issues/96 I was unable to add a test case, since that would require a server on a well-known port, but I manually verified that the GitHub/S3 signing issue was indeed resolved with this patch.
Diffstat (limited to 'lib/inets/src/http_client/httpc_response.erl')
-rw-r--r--lib/inets/src/http_client/httpc_response.erl3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/inets/src/http_client/httpc_response.erl b/lib/inets/src/http_client/httpc_response.erl
index 0fd5faa466..5fbceb8ad0 100644
--- a/lib/inets/src/http_client/httpc_response.erl
+++ b/lib/inets/src/http_client/httpc_response.erl
@@ -362,8 +362,9 @@ redirect(Response = {StatusLine, Headers, Body}, Request) ->
{ok, error(Request, Reason), Data};
%% Automatic redirection
{ok, {Scheme, _, Host, Port, Path, Query}} ->
+ HostPort = http_request:normalize_host(Scheme, Host, Port),
NewHeaders =
- (Request#request.headers)#http_request_h{host = Host++":"++integer_to_list(Port)},
+ (Request#request.headers)#http_request_h{host = HostPort},
NewRequest =
Request#request{redircount =
Request#request.redircount+1,