summaryrefslogtreecommitdiff
path: root/lib/inets/test
diff options
context:
space:
mode:
authorIngela Anderton Andin <ingela@erlang.org>2022-10-07 15:04:27 +0200
committerIngela Anderton Andin <ingela@erlang.org>2022-10-07 15:04:27 +0200
commit3121eff84f328203e39dabf81ec70d360208657a (patch)
treeb8ae850862e36489bf0c2277743d211b341aaa28 /lib/inets/test
parent39f4e7d7822820455d6a74d9e57dfad148dab1a0 (diff)
parent4bded9cb0fa088f1b6ccc530a6f7aa0fed4d49cd (diff)
downloaderlang-3121eff84f328203e39dabf81ec70d360208657a.tar.gz
Merge branch 'maint'
Diffstat (limited to 'lib/inets/test')
-rw-r--r--lib/inets/test/httpc_SUITE.erl36
-rw-r--r--lib/inets/test/httpd_poll.erl1
-rw-r--r--lib/inets/test/httpd_time_test.erl1
3 files changed, 38 insertions, 0 deletions
diff --git a/lib/inets/test/httpc_SUITE.erl b/lib/inets/test/httpc_SUITE.erl
index a3e3213838..68f1c71850 100644
--- a/lib/inets/test/httpc_SUITE.erl
+++ b/lib/inets/test/httpc_SUITE.erl
@@ -183,6 +183,7 @@ only_simulated() ->
redirect_found,
redirect_see_other,
redirect_temporary_redirect,
+ redirect_permanent_redirect,
redirect_relative_uri,
port_in_host_header,
redirect_port_in_host_header,
@@ -760,6 +761,26 @@ redirect_temporary_redirect(Config) when is_list(Config) ->
= httpc:request(post, {URL307, [],"text/plain", "foobar"},
[], []).
%%-------------------------------------------------------------------------
+redirect_permanent_redirect() ->
+ [{doc, "The server SHOULD generate a Location header field in the response "
+ "containing a preferred URI reference for the new permanent URI. "
+ "The user agent MAY use the Location field value for automatic redirection. "
+ "The server's response content usually contains a short hypertext note with "
+ "a hyperlink to the new URI(s)."}].
+redirect_permanent_redirect(Config) when is_list(Config) ->
+
+ URL308 = url(group_name(Config), "/308.html", Config),
+
+ {ok, {{_,200,_}, [_ | _], [_|_]}}
+ = httpc:request(get, {URL308, []}, [], []),
+
+ {ok, {{_,200,_}, [_ | _], []}}
+ = httpc:request(head, {URL308, []}, [], []),
+
+ {ok, {{_,200,_}, [_ | _], [_|_]}}
+ = httpc:request(post, {URL308, [],"text/plain", "foobar"},
+ [], []).
+%%-------------------------------------------------------------------------
redirect_relative_uri() ->
[{doc, "The server SHOULD generate a Location header field in the response "
"containing a preferred URI reference for the new permanent URI. The user "
@@ -2607,6 +2628,21 @@ handle_uri(_,"/307.html",Port,_,Socket,_) ->
"Location:" ++ NewUri ++ "\r\n" ++
"Content-Length:" ++ integer_to_list(length(Body))
++ "\r\n\r\n" ++ Body;
+handle_uri("HEAD","/308.html",Port,_,Socket,_) ->
+ NewUri = url_start(Socket) ++
+ integer_to_list(Port) ++ "/dummy.html",
+ "HTTP/1.1 308 Permanent Redirect \r\n" ++
+ "Location:" ++ NewUri ++ "\r\n" ++
+ "Content-Length:0\r\n\r\n";
+handle_uri(_,"/308.html",Port,_,Socket,_) ->
+ NewUri = url_start(Socket) ++
+ integer_to_list(Port) ++ "/dummy.html",
+ Body = "<HTML><BODY><a href=" ++ NewUri ++
+ ">New place</a></BODY></HTML>",
+ "HTTP/1.1 308 Permanent Redirect \r\n" ++
+ "Location:" ++ NewUri ++ "\r\n" ++
+ "Content-Length:" ++ integer_to_list(length(Body))
+ ++ "\r\n\r\n" ++ Body;
handle_uri(_,"/404.html",_,_,_,_) ->
"HTTP/1.1 404 not found\r\n" ++
diff --git a/lib/inets/test/httpd_poll.erl b/lib/inets/test/httpd_poll.erl
index f86e3a979b..d28a68c0c6 100644
--- a/lib/inets/test/httpd_poll.erl
+++ b/lib/inets/test/httpd_poll.erl
@@ -332,6 +332,7 @@ status_to_message(303) -> "Section 10.3.4: See Other";
status_to_message(304) -> "Section 10.3.5: Not Modified";
status_to_message(305) -> "Section 10.3.6: Use Proxy";
status_to_message(307) -> "Section 10.3.8: Temporary Redirect";
+status_to_message(308) -> "RFC 9110, Section 15.4.9: Permanent Redirect";
status_to_message(400) -> "Section 10.4.1: Bad Request";
status_to_message(401) -> "Section 10.4.2: Unauthorized";
status_to_message(402) -> "Section 10.4.3: Peyment Required";
diff --git a/lib/inets/test/httpd_time_test.erl b/lib/inets/test/httpd_time_test.erl
index 87a913fce4..d00dc40e61 100644
--- a/lib/inets/test/httpd_time_test.erl
+++ b/lib/inets/test/httpd_time_test.erl
@@ -450,6 +450,7 @@ status_to_message(303) -> "Section 10.3.4: See Other";
status_to_message(304) -> "Section 10.3.5: Not Modified";
status_to_message(305) -> "Section 10.3.6: Use Proxy";
status_to_message(307) -> "Section 10.3.8: Temporary Redirect";
+status_to_message(308) -> "RFC 9110, Section 15.4.9: Permanent Redirect";
status_to_message(400) -> "Section 10.4.1: Bad Request";
status_to_message(401) -> "Section 10.4.2: Unauthorized";
status_to_message(402) -> "Section 10.4.3: Peyment Required";