Mercurial > hg > nginx-tests
changeset 1731:c9b4c0ef5059
Tests: added server_name_in_redirect and port_in_redirect tests.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Wed, 15 Sep 2021 18:04:24 +0300 |
parents | 696322b7e2c3 |
children | 41ca4b00c2d0 |
files | http_absolute_redirect.t |
diffstat | 1 files changed, 22 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/http_absolute_redirect.t +++ b/http_absolute_redirect.t @@ -42,6 +42,7 @@ http { server_name on; absolute_redirect on; + error_page 400 /return301; location / { } @@ -57,6 +58,16 @@ http { 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 @@ EOF mkdir($t->testdir() . '/dir'); mkdir($t->testdir() . '/dir sp'); -$t->run()->plan(19); +$t->run()->plan(23); ############################################################################### @@ -134,6 +145,16 @@ like(get('on', '/auto%20sp?a=b'), 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');