comparison http_absolute_redirect.t @ 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 14b5ee6eee6c
children 2a0a6035a1af
comparison
equal deleted inserted replaced
1730:696322b7e2c3 1731:c9b4c0ef5059
40 server { 40 server {
41 listen 127.0.0.1:8080; 41 listen 127.0.0.1:8080;
42 server_name on; 42 server_name on;
43 43
44 absolute_redirect on; 44 absolute_redirect on;
45 error_page 400 /return301;
45 46
46 location / { } 47 location / { }
47 48
48 location /auto/ { 49 location /auto/ {
49 proxy_pass http://127.0.0.1:8080; 50 proxy_pass http://127.0.0.1:8080;
53 proxy_pass http://127.0.0.1:8080; 54 proxy_pass http://127.0.0.1:8080;
54 } 55 }
55 56
56 location /return301 { 57 location /return301 {
57 return 301 /redirect; 58 return 301 /redirect;
59 }
60
61 location /return301/name {
62 return 301 /redirect;
63 server_name_in_redirect on;
64 }
65
66 location /return301/port {
67 return 301 /redirect;
68 port_in_redirect off;
58 } 69 }
59 70
60 location /i/ { 71 location /i/ {
61 alias %%TESTDIR%%/; 72 alias %%TESTDIR%%/;
62 } 73 }
93 EOF 104 EOF
94 105
95 mkdir($t->testdir() . '/dir'); 106 mkdir($t->testdir() . '/dir');
96 mkdir($t->testdir() . '/dir sp'); 107 mkdir($t->testdir() . '/dir sp');
97 108
98 $t->run()->plan(19); 109 $t->run()->plan(23);
99 110
100 ############################################################################### 111 ###############################################################################
101 112
102 my $p = port(8080); 113 my $p = port(8080);
103 114
132 } 143 }
133 144
134 like(get('on', '/return301'), qr!Location: http://on:$p/redirect\x0d?$!m, 145 like(get('on', '/return301'), qr!Location: http://on:$p/redirect\x0d?$!m,
135 'return'); 146 'return');
136 147
148 like(get('host', '/return301/name'), qr!Location: http://on:$p/redirect\x0d?!m,
149 'server_name_in_redirect on');
150 like(get('host', '/return301'), qr!Location: http://host:$p/redirect\x0d?$!m,
151 'server_name_in_redirect off - using host');
152 my $ph = IO::Socket::INET->new("127.0.0.1:$p")->peerhost();
153 like(get('.', '/return301'), qr!Location: http://$ph:$p/redirect\x0d?$!m,
154 'invalid host - using local sockaddr');
155 like(get('host', '/return301/port'), qr!Location: http://host/redirect\x0d?$!m,
156 'port_in_redirect off');
157
137 like(get('off', '/dir'), qr!Location: /dir/\x0d?$!m, 'off directory'); 158 like(get('off', '/dir'), qr!Location: /dir/\x0d?$!m, 'off directory');
138 like(get('off', '/i/dir'), qr!Location: /i/dir/\x0d?$!m, 'off directory alias'); 159 like(get('off', '/i/dir'), qr!Location: /i/dir/\x0d?$!m, 'off directory alias');
139 160
140 TODO: { 161 TODO: {
141 local $TODO = 'not yet' unless $t->has_version('1.21.0'); 162 local $TODO = 'not yet' unless $t->has_version('1.21.0');