From 4b9b5cc645e060fb55e45f88597badf32dd1c985 Mon Sep 17 00:00:00 2001 From: Hans Svensson Date: Thu, 17 Jan 2013 22:31:49 +0100 Subject: inets - httpc_SUITE: add redirect tests for response 303 httpc contains code for redirecting http response 301, 302, 303, and 307, but no tests existed for response '303 See Other'. Added tests (get, head, and post) for 303 and renumbered tests for 307. The subtle thing is that for 303 also post requests *should* be redirected. Also added the necessary 303 page to the dummy_server. --- lib/inets/test/httpc_SUITE.erl | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) (limited to 'lib/inets/test/httpc_SUITE.erl') diff --git a/lib/inets/test/httpc_SUITE.erl b/lib/inets/test/httpc_SUITE.erl index 644b01120c..fbd1b3d38a 100644 --- a/lib/inets/test/httpc_SUITE.erl +++ b/lib/inets/test/httpc_SUITE.erl @@ -1326,24 +1326,42 @@ http_redirect(Config) when is_list(Config) -> = httpc:request(post, {URL302, [],"text/plain", "foobar"}, [], []), - URL307 = ?URL_START ++ integer_to_list(Port) ++ "/307.html", + URL303 = ?URL_START ++ integer_to_list(Port) ++ "/303.html", tsp("http_redirect -> issue request 9: " + "~n ~p", [URL303]), + {ok, {{_,200,_}, [_ | _], [_|_]}} + = httpc:request(get, {URL303, []}, [], []), + + tsp("http_redirect -> issue request 10: " + "~n ~p", [URL303]), + {ok, {{_,200,_}, [_ | _], []}} + = httpc:request(head, {URL303, []}, [], []), + + tsp("http_redirect -> issue request 11: " + "~n ~p", [URL303]), + {ok, {{_,200,_}, [_ | _], [_|_]}} + = httpc:request(post, {URL303, [],"text/plain", "foobar"}, + [], []), + + URL307 = ?URL_START ++ integer_to_list(Port) ++ "/307.html", + + tsp("http_redirect -> issue request 12: " "~n ~p", [URL307]), {ok, {{_,200,_}, [_ | _], [_|_]}} = httpc:request(get, {URL307, []}, [], []), - tsp("http_redirect -> issue request 10: " + tsp("http_redirect -> issue request 13: " "~n ~p", [URL307]), {ok, {{_,200,_}, [_ | _], []}} = httpc:request(head, {URL307, []}, [], []), - tsp("http_redirect -> issue request 11: " + tsp("http_redirect -> issue request 14: " "~n ~p", [URL307]), {ok, {{_,307,_}, [_ | _], [_|_]}} = httpc:request(post, {URL307, [],"text/plain", "foobar"}, [], []), - + tsp("http_redirect -> stop dummy server"), DummyServerPid ! stop, tsp("http_redirect -> reset ipfamily option (to inet6fb4)"), @@ -3298,6 +3316,14 @@ handle_http_msg({_, RelUri, _, {_, Headers}, Body}, Socket, Close, Send) -> "Content-Length:80\r\n\r\n" ++ "New place"; + "/303.html" -> + NewUri = ?URL_START ++ + integer_to_list(?IP_PORT) ++ "/dummy.html", + "HTTP/1.1 303 See Other \r\n" ++ + "Location:" ++ NewUri ++ "\r\n" ++ + "Content-Length:80\r\n\r\n" ++ + "New place"; "/307.html" -> NewUri = ?URL_START ++ integer_to_list(?IP_PORT) ++ "/dummy.html", -- cgit v1.2.3