Tests: added server_name_in_redirect and port_in_redirect tests.
diff --git a/http_absolute_redirect.t b/http_absolute_redirect.t
index 9c12e96..ff3bb13 100644
--- a/http_absolute_redirect.t
+++ b/http_absolute_redirect.t
@@ -42,6 +42,7 @@
server_name on;
absolute_redirect on;
+ error_page 400 /return301;
location / { }
@@ -57,6 +58,16 @@
return 301 /redirect;
}
+ location /return301/name {
+ return 301 /redirect;
+ server_name_in_redirect on;
+ }
+
+ location /return301/port {
+ return 301 /redirect;
+ port_in_redirect off;
+ }
+
location /i/ {
alias %%TESTDIR%%/;
}
@@ -95,7 +106,7 @@
mkdir($t->testdir() . '/dir');
mkdir($t->testdir() . '/dir sp');
-$t->run()->plan(19);
+$t->run()->plan(23);
###############################################################################
@@ -134,6 +145,16 @@
like(get('on', '/return301'), qr!Location: http://on:$p/redirect\x0d?$!m,
'return');
+like(get('host', '/return301/name'), qr!Location: http://on:$p/redirect\x0d?!m,
+ 'server_name_in_redirect on');
+like(get('host', '/return301'), qr!Location: http://host:$p/redirect\x0d?$!m,
+ 'server_name_in_redirect off - using host');
+my $ph = IO::Socket::INET->new("127.0.0.1:$p")->peerhost();
+like(get('.', '/return301'), qr!Location: http://$ph:$p/redirect\x0d?$!m,
+ 'invalid host - using local sockaddr');
+like(get('host', '/return301/port'), qr!Location: http://host/redirect\x0d?$!m,
+ 'port_in_redirect off');
+
like(get('off', '/dir'), qr!Location: /dir/\x0d?$!m, 'off directory');
like(get('off', '/i/dir'), qr!Location: /i/dir/\x0d?$!m, 'off directory alias');