diff options
author | Ross Schlaikjer <[email protected]> | 2018-07-03 17:14:28 +0000 |
---|---|---|
committer | Ross Schlaikjer <[email protected]> | 2018-07-06 08:46:15 -0400 |
commit | bd890e1859c97297a06166e5f92e8c33b1db4682 (patch) | |
tree | a8a38bc734f11847ae6f607b26ab8f76cccdfa90 /lib/inets/test | |
parent | 9993d349a8abcb7ba07bebcc8cc71ecec291ca68 (diff) | |
download | otp-bd890e1859c97297a06166e5f92e8c33b1db4682.tar.gz otp-bd890e1859c97297a06166e5f92e8c33b1db4682.tar.bz2 otp-bd890e1859c97297a06166e5f92e8c33b1db4682.zip |
Add test case on relative redirects with ports
Diffstat (limited to 'lib/inets/test')
-rw-r--r-- | lib/inets/test/httpc_SUITE.erl | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/lib/inets/test/httpc_SUITE.erl b/lib/inets/test/httpc_SUITE.erl index 0440cb302c..6e048a4d56 100644 --- a/lib/inets/test/httpc_SUITE.erl +++ b/lib/inets/test/httpc_SUITE.erl @@ -174,7 +174,8 @@ misc() -> sim_mixed() -> [ - redirect_http_to_https + redirect_http_to_https, + redirect_relative_different_port ]. %%-------------------------------------------------------------------- @@ -767,6 +768,30 @@ redirect_http_to_https(Config) when is_list(Config) -> = httpc:request(post, {URL301, Headers, "text/plain", "foobar"}, [], []). %%------------------------------------------------------------------------- +redirect_relative_different_port() -> + [{doc, "Test that a 30X redirect with a relative target, but different " + "port, is handled correctly."}]. +redirect_relative_different_port(Config) when is_list(Config) -> + URL301 = mixed_url(http, "/301_custom_url.html", Config), + + % We need an extra server of the same protocol here, so spawn a new + % HTTP-protocol one + Port = server_start(sim_http, []), + {ok, Host} = inet:gethostname(), + % Prefix the URI with '/' instead of a scheme + TargetUrl = "//" ++ Host ++ ":" ++ integer_to_list(Port) ++ "/dummy.html", + Headers = [{"x-test-301-url", TargetUrl}], + + {ok, {{_,200,_}, [_ | _], [_|_]}} + = httpc:request(get, {URL301, Headers}, [], []), + + {ok, {{_,200,_}, [_ | _], []}} + = httpc:request(head, {URL301, Headers}, [], []), + + {ok, {{_,200,_}, [_ | _], [_|_]}} + = httpc:request(post, {URL301, Headers, "text/plain", "foobar"}, + [], []). +%%------------------------------------------------------------------------- cookie() -> [{doc, "Test cookies."}]. cookie(Config) when is_list(Config) -> |