diff options
author | Ingela Anderton Andin <[email protected]> | 2016-12-16 11:30:45 +0100 |
---|---|---|
committer | Ingela Anderton Andin <[email protected]> | 2016-12-16 11:30:45 +0100 |
commit | fed14f418d0bbf8326888376ae0e0453e26d84b2 (patch) | |
tree | 9f3be2789e972be1207d0a03df01eed37316a714 | |
parent | faba74ce9315cbbfa99d111290a063916d2b3b64 (diff) | |
parent | 3018e0c0df040524de17cba97314f32e9c63214f (diff) | |
download | otp-fed14f418d0bbf8326888376ae0e0453e26d84b2.tar.gz otp-fed14f418d0bbf8326888376ae0e0453e26d84b2.tar.bz2 otp-fed14f418d0bbf8326888376ae0e0453e26d84b2.zip |
Merge branch 'ingela/inets/httpc-redirect-host-header/ERL-316/OTP-14097' into maint
* ingela/inets/httpc-redirect-host-header/ERL-316/OTP-14097:
inets: httpc - Correct redirection host header
-rw-r--r-- | lib/inets/src/http_client/httpc_response.erl | 2 | ||||
-rw-r--r-- | lib/inets/test/httpc_SUITE.erl | 13 |
2 files changed, 14 insertions, 1 deletions
diff --git a/lib/inets/src/http_client/httpc_response.erl b/lib/inets/src/http_client/httpc_response.erl index d8bdac24e3..0fd5faa466 100644 --- a/lib/inets/src/http_client/httpc_response.erl +++ b/lib/inets/src/http_client/httpc_response.erl @@ -363,7 +363,7 @@ redirect(Response = {StatusLine, Headers, Body}, Request) -> %% Automatic redirection {ok, {Scheme, _, Host, Port, Path, Query}} -> NewHeaders = - (Request#request.headers)#http_request_h{host = Host}, + (Request#request.headers)#http_request_h{host = Host++":"++integer_to_list(Port)}, NewRequest = Request#request{redircount = Request#request.redircount+1, diff --git a/lib/inets/test/httpc_SUITE.erl b/lib/inets/test/httpc_SUITE.erl index a64ae2b87c..b2d0ce7631 100644 --- a/lib/inets/test/httpc_SUITE.erl +++ b/lib/inets/test/httpc_SUITE.erl @@ -125,6 +125,7 @@ only_simulated() -> redirect_see_other, redirect_temporary_redirect, port_in_host_header, + redirect_port_in_host_header, relaxed ]. @@ -1102,6 +1103,12 @@ port_in_host_header(Config) when is_list(Config) -> Request = {url(group_name(Config), "/ensure_host_header_with_port.html", Config), []}, {ok, {{_, 200, _}, _, Body}} = httpc:request(get, Request, [], []), inets_test_lib:check_body(Body). +%%------------------------------------------------------------------------- +redirect_port_in_host_header(Config) when is_list(Config) -> + + Request = {url(group_name(Config), "/redirect_ensure_host_header_with_port.html", Config), []}, + {ok, {{_, 200, _}, _, Body}} = httpc:request(get, Request, [], []), + inets_test_lib:check_body(Body). %%------------------------------------------------------------------------- timeout_memory_leak() -> @@ -1680,6 +1687,12 @@ handle_uri(_,"/ensure_host_header_with_port.html",_,Headers,_,_) -> "HTTP/1.1 500 Internal Server Error\r\n" ++ "Content-Length:" ++ Len ++ "\r\n\r\n" ++ B end; +handle_uri(_,"/redirect_ensure_host_header_with_port.html",Port,_,Socket,_) -> + NewUri = url_start(Socket) ++ + integer_to_list(Port) ++ "/ensure_host_header_with_port.html", + "HTTP/1.1 302 Found \r\n" ++ + "Location:" ++ NewUri ++ "\r\n" ++ + "Content-Length:0\r\n\r\n"; handle_uri(_,"/300.html",Port,_,Socket,_) -> NewUri = url_start(Socket) ++ |