aboutsummaryrefslogtreecommitdiffstats
path: root/lib/inets/test/httpc_SUITE.erl
diff options
context:
space:
mode:
authorJohannes Weißl <[email protected]>2017-05-14 23:35:37 +0200
committerJohannes Weißl <[email protected]>2017-05-23 08:44:03 +0200
commitfb4c7f27d050a167335a4274327cf1f8d8cc9aba (patch)
treed5fdc342a61dcda6f82e56b1b1a5a59e3f481206 /lib/inets/test/httpc_SUITE.erl
parentdfbefdcc85b2785e4d2280c1b70de8fd14a6778d (diff)
downloadotp-fb4c7f27d050a167335a4274327cf1f8d8cc9aba.tar.gz
otp-fb4c7f27d050a167335a4274327cf1f8d8cc9aba.tar.bz2
otp-fb4c7f27d050a167335a4274327cf1f8d8cc9aba.zip
Fix httpc timeout for redirects
Probably since 6153ba7 (OTP R13B04) the httpc timeout setting does not work for redirects (when autoredirect is true). With this patch a new timer is started for the new (redirected) requests. This means that a simple redirected request could return after 2*timeout milliseconds. This is the first part to fix https://bugs.erlang.org/browse/ERL-420
Diffstat (limited to 'lib/inets/test/httpc_SUITE.erl')
-rw-r--r--lib/inets/test/httpc_SUITE.erl19
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/inets/test/httpc_SUITE.erl b/lib/inets/test/httpc_SUITE.erl
index fc7f01245b..e6dcd2285f 100644
--- a/lib/inets/test/httpc_SUITE.erl
+++ b/lib/inets/test/httpc_SUITE.erl
@@ -108,6 +108,7 @@ only_simulated() ->
tolerate_missing_CR,
userinfo,
bad_response,
+ timeout_redirect,
internal_server_error,
invalid_http,
invalid_chunk_size,
@@ -785,6 +786,14 @@ bad_response(Config) when is_list(Config) ->
ct:print("Wrong Statusline: ~p~n", [Reason]).
%%-------------------------------------------------------------------------
+timeout_redirect() ->
+ [{doc, "Test that timeout works for redirects, check ERL-420."}].
+timeout_redirect(Config) when is_list(Config) ->
+ URL = url(group_name(Config), "/redirect_to_missing_crlf.html", Config),
+ {error, timeout} = httpc:request(get, {URL, []}, [{timeout, 400}], []).
+
+%%-------------------------------------------------------------------------
+
internal_server_error(doc) ->
["Test 50X codes"];
internal_server_error(Config) when is_list(Config) ->
@@ -1915,6 +1924,16 @@ handle_uri(_,"/missing_crlf.html",_,_,_,_) ->
"Content-Length:32\r\n" ++
"<HTML><BODY>foobar</BODY></HTML>";
+handle_uri(_,"/redirect_to_missing_crlf.html",Port,_,Socket,_) ->
+ NewUri = url_start(Socket) ++
+ integer_to_list(Port) ++ "/missing_crlf.html",
+ Body = "<HTML><BODY><a href=" ++ NewUri ++
+ ">New place</a></BODY></HTML>",
+ "HTTP/1.1 303 See Other \r\n" ++
+ "Location:" ++ NewUri ++ "\r\n" ++
+ "Content-Length:" ++ integer_to_list(length(Body))
+ ++ "\r\n\r\n" ++ Body;
+
handle_uri(_,"/wrong_statusline.html",_,_,_,_) ->
"ok 200 HTTP/1.1\r\n\r\n" ++
"Content-Length:32\r\n\r\n" ++