Mercurial > hg > nginx-tests
annotate h2_absolute_redirect.t @ 1990:85d88cd5091c
Tests: SSI include stub tests.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Thu, 04 Jul 2024 17:42:55 +0300 |
parents | 11463d379570 |
children |
rev | line source |
---|---|
1103
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
2 |
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
3 # (C) Sergey Kandaurov |
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
4 # (C) Nginx, Inc. |
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
5 |
1691
0d8531f744bc
Tests: added Location header escaping tests (ticket #882).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
6 # Tests for absolute_redirect directive and Location escaping. |
1103
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
7 |
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
8 ############################################################################### |
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
9 |
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
10 use warnings; |
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
11 use strict; |
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
12 |
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
13 use Test::More; |
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
14 |
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
15 BEGIN { use FindBin; chdir($FindBin::Bin); } |
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
16 |
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
17 use lib 'lib'; |
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
18 use Test::Nginx; |
1732
41ca4b00c2d0
Tests: added absolute_redirect and Location tests for HTTP/2.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1731
diff
changeset
|
19 use Test::Nginx::HTTP2; |
1103
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
20 |
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
21 ############################################################################### |
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
22 |
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
23 select STDERR; $| = 1; |
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
24 select STDOUT; $| = 1; |
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
25 |
1732
41ca4b00c2d0
Tests: added absolute_redirect and Location tests for HTTP/2.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1731
diff
changeset
|
26 my $t = Test::Nginx->new()->has(qw/http http_v2 proxy rewrite/) |
1103
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
27 ->write_file_expand('nginx.conf', <<'EOF'); |
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
28 |
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
29 %%TEST_GLOBALS%% |
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
30 |
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
31 daemon off; |
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
32 |
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
33 events { |
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
34 } |
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
35 |
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
36 http { |
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
37 %%TEST_GLOBALS_HTTP%% |
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
38 |
1986
11463d379570
Tests: reworked HTTP/2 tests to use "http2 on".
Maxim Dounin <mdounin@mdounin.ru>
parents:
1937
diff
changeset
|
39 http2 on; |
1103
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
40 absolute_redirect off; |
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
41 |
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
42 server { |
1986
11463d379570
Tests: reworked HTTP/2 tests to use "http2 on".
Maxim Dounin <mdounin@mdounin.ru>
parents:
1937
diff
changeset
|
43 listen 127.0.0.1:8080; |
1103
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
44 server_name on; |
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
45 |
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
46 absolute_redirect on; |
1731
c9b4c0ef5059
Tests: added server_name_in_redirect and port_in_redirect tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1729
diff
changeset
|
47 error_page 400 /return301; |
1103
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
48 |
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
49 location / { } |
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
50 |
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
51 location /auto/ { |
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
52 proxy_pass http://127.0.0.1:8080; |
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
53 } |
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
54 |
1691
0d8531f744bc
Tests: added Location header escaping tests (ticket #882).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
55 location "/auto sp/" { |
0d8531f744bc
Tests: added Location header escaping tests (ticket #882).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
56 proxy_pass http://127.0.0.1:8080; |
0d8531f744bc
Tests: added Location header escaping tests (ticket #882).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
57 } |
0d8531f744bc
Tests: added Location header escaping tests (ticket #882).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
58 |
1103
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
59 location /return301 { |
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
60 return 301 /redirect; |
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
61 } |
1150
ccf134a800ae
Tests: added Location tests with alias for dav and static modules.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1103
diff
changeset
|
62 |
1731
c9b4c0ef5059
Tests: added server_name_in_redirect and port_in_redirect tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1729
diff
changeset
|
63 location /return301/name { |
c9b4c0ef5059
Tests: added server_name_in_redirect and port_in_redirect tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1729
diff
changeset
|
64 return 301 /redirect; |
c9b4c0ef5059
Tests: added server_name_in_redirect and port_in_redirect tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1729
diff
changeset
|
65 server_name_in_redirect on; |
c9b4c0ef5059
Tests: added server_name_in_redirect and port_in_redirect tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1729
diff
changeset
|
66 } |
c9b4c0ef5059
Tests: added server_name_in_redirect and port_in_redirect tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1729
diff
changeset
|
67 |
c9b4c0ef5059
Tests: added server_name_in_redirect and port_in_redirect tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1729
diff
changeset
|
68 location /return301/port { |
c9b4c0ef5059
Tests: added server_name_in_redirect and port_in_redirect tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1729
diff
changeset
|
69 return 301 /redirect; |
c9b4c0ef5059
Tests: added server_name_in_redirect and port_in_redirect tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1729
diff
changeset
|
70 port_in_redirect off; |
c9b4c0ef5059
Tests: added server_name_in_redirect and port_in_redirect tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1729
diff
changeset
|
71 } |
c9b4c0ef5059
Tests: added server_name_in_redirect and port_in_redirect tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1729
diff
changeset
|
72 |
1150
ccf134a800ae
Tests: added Location tests with alias for dav and static modules.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1103
diff
changeset
|
73 location /i/ { |
ccf134a800ae
Tests: added Location tests with alias for dav and static modules.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1103
diff
changeset
|
74 alias %%TESTDIR%%/; |
ccf134a800ae
Tests: added Location tests with alias for dav and static modules.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1103
diff
changeset
|
75 } |
1103
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
76 } |
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
77 |
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
78 server { |
1986
11463d379570
Tests: reworked HTTP/2 tests to use "http2 on".
Maxim Dounin <mdounin@mdounin.ru>
parents:
1937
diff
changeset
|
79 listen 127.0.0.1:8080; |
1103
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
80 server_name off; |
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
81 |
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
82 location / { } |
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
83 |
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
84 location /auto/ { |
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
85 proxy_pass http://127.0.0.1:8080; |
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
86 } |
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
87 |
1691
0d8531f744bc
Tests: added Location header escaping tests (ticket #882).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
88 location "/auto sp/" { |
0d8531f744bc
Tests: added Location header escaping tests (ticket #882).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
89 proxy_pass http://127.0.0.1:8080; |
0d8531f744bc
Tests: added Location header escaping tests (ticket #882).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
90 } |
0d8531f744bc
Tests: added Location header escaping tests (ticket #882).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
91 |
1713
77a9e393ed46
Tests: added one more Location header escaping test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1691
diff
changeset
|
92 location '/auto "#%<>?\^`{|}/' { |
77a9e393ed46
Tests: added one more Location header escaping test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1691
diff
changeset
|
93 proxy_pass http://127.0.0.1:8080; |
77a9e393ed46
Tests: added one more Location header escaping test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1691
diff
changeset
|
94 } |
77a9e393ed46
Tests: added one more Location header escaping test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1691
diff
changeset
|
95 |
1103
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
96 location /return301 { |
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
97 return 301 /redirect; |
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
98 } |
1150
ccf134a800ae
Tests: added Location tests with alias for dav and static modules.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1103
diff
changeset
|
99 |
ccf134a800ae
Tests: added Location tests with alias for dav and static modules.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1103
diff
changeset
|
100 location /i/ { |
ccf134a800ae
Tests: added Location tests with alias for dav and static modules.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1103
diff
changeset
|
101 alias %%TESTDIR%%/; |
ccf134a800ae
Tests: added Location tests with alias for dav and static modules.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1103
diff
changeset
|
102 } |
1103
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
103 } |
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
104 } |
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
105 |
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
106 EOF |
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
107 |
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
108 mkdir($t->testdir() . '/dir'); |
1691
0d8531f744bc
Tests: added Location header escaping tests (ticket #882).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
109 mkdir($t->testdir() . '/dir sp'); |
1103
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
110 |
1731
c9b4c0ef5059
Tests: added server_name_in_redirect and port_in_redirect tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1729
diff
changeset
|
111 $t->run()->plan(23); |
1103
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
112 |
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
113 ############################################################################### |
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
114 |
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
115 my $p = port(8080); |
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
116 |
1153
818fbc9d1c29
Tests: check Location EoLs in http_absolute_redirect.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1150
diff
changeset
|
117 like(get('on', '/dir'), qr!Location: http://on:$p/dir/\x0d?$!m, 'directory'); |
818fbc9d1c29
Tests: check Location EoLs in http_absolute_redirect.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1150
diff
changeset
|
118 like(get('on', '/i/dir'), qr!Location: http://on:$p/i/dir/\x0d?$!m, |
818fbc9d1c29
Tests: check Location EoLs in http_absolute_redirect.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1150
diff
changeset
|
119 'directory alias'); |
1691
0d8531f744bc
Tests: added Location header escaping tests (ticket #882).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
120 |
0d8531f744bc
Tests: added Location header escaping tests (ticket #882).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
121 like(get('on', '/dir%20sp'), qr!Location: http://on:$p/dir%20sp/\x0d?$!m, |
0d8531f744bc
Tests: added Location header escaping tests (ticket #882).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
122 'directory escaped'); |
0d8531f744bc
Tests: added Location header escaping tests (ticket #882).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
123 like(get('on', '/dir%20sp?a=b'), |
0d8531f744bc
Tests: added Location header escaping tests (ticket #882).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
124 qr!Location: http://on:$p/dir%20sp/\?a=b\x0d?$!m, |
0d8531f744bc
Tests: added Location header escaping tests (ticket #882).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
125 'directory escaped args'); |
0d8531f744bc
Tests: added Location header escaping tests (ticket #882).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
126 |
1153
818fbc9d1c29
Tests: check Location EoLs in http_absolute_redirect.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1150
diff
changeset
|
127 like(get('on', '/auto'), qr!Location: http://on:$p/auto/\x0d?$!m, 'auto'); |
1154
2c120aea4362
Tests: added auto redirect tests with args.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1153
diff
changeset
|
128 like(get('on', '/auto?a=b'), qr!Location: http://on:$p/auto/\?a=b\x0d?$!m, |
2c120aea4362
Tests: added auto redirect tests with args.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1153
diff
changeset
|
129 'auto args'); |
1691
0d8531f744bc
Tests: added Location header escaping tests (ticket #882).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
130 |
0d8531f744bc
Tests: added Location header escaping tests (ticket #882).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
131 like(get('on', '/auto%20sp'), qr!Location: http://on:$p/auto%20sp/\x0d?$!m, |
0d8531f744bc
Tests: added Location header escaping tests (ticket #882).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
132 'auto escaped'); |
0d8531f744bc
Tests: added Location header escaping tests (ticket #882).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
133 like(get('on', '/auto%20sp?a=b'), |
0d8531f744bc
Tests: added Location header escaping tests (ticket #882).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
134 qr!Location: http://on:$p/auto%20sp/\?a=b\x0d?$!m, |
0d8531f744bc
Tests: added Location header escaping tests (ticket #882).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
135 'auto escaped args'); |
0d8531f744bc
Tests: added Location header escaping tests (ticket #882).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
136 |
1153
818fbc9d1c29
Tests: check Location EoLs in http_absolute_redirect.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1150
diff
changeset
|
137 like(get('on', '/return301'), qr!Location: http://on:$p/redirect\x0d?$!m, |
818fbc9d1c29
Tests: check Location EoLs in http_absolute_redirect.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1150
diff
changeset
|
138 'return'); |
1103
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
139 |
1731
c9b4c0ef5059
Tests: added server_name_in_redirect and port_in_redirect tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1729
diff
changeset
|
140 like(get('host', '/return301/name'), qr!Location: http://on:$p/redirect\x0d?!m, |
c9b4c0ef5059
Tests: added server_name_in_redirect and port_in_redirect tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1729
diff
changeset
|
141 'server_name_in_redirect on'); |
c9b4c0ef5059
Tests: added server_name_in_redirect and port_in_redirect tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1729
diff
changeset
|
142 like(get('host', '/return301'), qr!Location: http://host:$p/redirect\x0d?$!m, |
c9b4c0ef5059
Tests: added server_name_in_redirect and port_in_redirect tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1729
diff
changeset
|
143 'server_name_in_redirect off - using host'); |
c9b4c0ef5059
Tests: added server_name_in_redirect and port_in_redirect tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1729
diff
changeset
|
144 my $ph = IO::Socket::INET->new("127.0.0.1:$p")->peerhost(); |
c9b4c0ef5059
Tests: added server_name_in_redirect and port_in_redirect tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1729
diff
changeset
|
145 like(get('.', '/return301'), qr!Location: http://$ph:$p/redirect\x0d?$!m, |
c9b4c0ef5059
Tests: added server_name_in_redirect and port_in_redirect tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1729
diff
changeset
|
146 'invalid host - using local sockaddr'); |
c9b4c0ef5059
Tests: added server_name_in_redirect and port_in_redirect tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1729
diff
changeset
|
147 like(get('host', '/return301/port'), qr!Location: http://host/redirect\x0d?$!m, |
c9b4c0ef5059
Tests: added server_name_in_redirect and port_in_redirect tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1729
diff
changeset
|
148 'port_in_redirect off'); |
c9b4c0ef5059
Tests: added server_name_in_redirect and port_in_redirect tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1729
diff
changeset
|
149 |
1153
818fbc9d1c29
Tests: check Location EoLs in http_absolute_redirect.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1150
diff
changeset
|
150 like(get('off', '/dir'), qr!Location: /dir/\x0d?$!m, 'off directory'); |
818fbc9d1c29
Tests: check Location EoLs in http_absolute_redirect.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1150
diff
changeset
|
151 like(get('off', '/i/dir'), qr!Location: /i/dir/\x0d?$!m, 'off directory alias'); |
1691
0d8531f744bc
Tests: added Location header escaping tests (ticket #882).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
152 |
0d8531f744bc
Tests: added Location header escaping tests (ticket #882).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
153 like(get('off', '/dir%20sp'), qr!Location: /dir%20sp/\x0d?$!m, |
0d8531f744bc
Tests: added Location header escaping tests (ticket #882).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
154 'off directory escaped'); |
0d8531f744bc
Tests: added Location header escaping tests (ticket #882).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
155 like(get('off', '/dir%20sp?a=b'), qr!Location: /dir%20sp/\?a=b\x0d?$!m, |
0d8531f744bc
Tests: added Location header escaping tests (ticket #882).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
156 'off directory escaped args'); |
0d8531f744bc
Tests: added Location header escaping tests (ticket #882).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
157 |
1153
818fbc9d1c29
Tests: check Location EoLs in http_absolute_redirect.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1150
diff
changeset
|
158 like(get('off', '/auto'), qr!Location: /auto/\x0d?$!m, 'off auto'); |
1154
2c120aea4362
Tests: added auto redirect tests with args.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1153
diff
changeset
|
159 like(get('off', '/auto?a=b'), qr!Location: /auto/\?a=b\x0d?$!m, |
2c120aea4362
Tests: added auto redirect tests with args.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1153
diff
changeset
|
160 'off auto args'); |
1691
0d8531f744bc
Tests: added Location header escaping tests (ticket #882).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
161 |
0d8531f744bc
Tests: added Location header escaping tests (ticket #882).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
162 like(get('off', '/auto%20sp'), qr!Location: /auto%20sp/\x0d?$!m, |
0d8531f744bc
Tests: added Location header escaping tests (ticket #882).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
163 'auto escaped'); |
0d8531f744bc
Tests: added Location header escaping tests (ticket #882).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
164 like(get('off', '/auto%20sp?a=b'), qr!Location: /auto%20sp/\?a=b\x0d?$!m, |
0d8531f744bc
Tests: added Location header escaping tests (ticket #882).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
165 'auto escaped args'); |
0d8531f744bc
Tests: added Location header escaping tests (ticket #882).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
166 |
1153
818fbc9d1c29
Tests: check Location EoLs in http_absolute_redirect.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1150
diff
changeset
|
167 like(get('off', '/return301'), qr!Location: /redirect\x0d?$!m, 'off return'); |
1103
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
168 |
1729 | 169 # per RFC 3986, these characters are not allowed unescaped: |
1713
77a9e393ed46
Tests: added one more Location header escaping test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1691
diff
changeset
|
170 # %00-%1F, %7F-%FF, " ", """, "<", ">", "\", "^", "`", "{", "|", "}" |
77a9e393ed46
Tests: added one more Location header escaping test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1691
diff
changeset
|
171 # additionally, all characters in ESCAPE_URI: "?", "%", "#" |
77a9e393ed46
Tests: added one more Location header escaping test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1691
diff
changeset
|
172 |
1718
672018971a62
Tests: skip Location header escaping test on win32.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1713
diff
changeset
|
173 SKIP: { |
672018971a62
Tests: skip Location header escaping test on win32.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1713
diff
changeset
|
174 skip 'win32', 1 if $^O eq 'MSWin32'; |
672018971a62
Tests: skip Location header escaping test on win32.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1713
diff
changeset
|
175 |
1713
77a9e393ed46
Tests: added one more Location header escaping test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1691
diff
changeset
|
176 like(get('off', '/auto%20%22%23%25%3C%3E%3F%5C%5E%60%7B%7C%7D'), |
77a9e393ed46
Tests: added one more Location header escaping test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1691
diff
changeset
|
177 qr!Location: /auto%20%22%23%25%3C%3E%3F%5C%5E%60%7B%7C%7D/\x0d?$!m, |
77a9e393ed46
Tests: added one more Location header escaping test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1691
diff
changeset
|
178 'auto escaped strict'); |
77a9e393ed46
Tests: added one more Location header escaping test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1691
diff
changeset
|
179 |
77a9e393ed46
Tests: added one more Location header escaping test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1691
diff
changeset
|
180 } |
77a9e393ed46
Tests: added one more Location header escaping test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1691
diff
changeset
|
181 |
1103
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
182 ############################################################################### |
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
183 |
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
184 sub get { |
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
185 my ($host, $uri) = @_; |
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
186 |
1732
41ca4b00c2d0
Tests: added absolute_redirect and Location tests for HTTP/2.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1731
diff
changeset
|
187 my $s = Test::Nginx::HTTP2->new(); |
41ca4b00c2d0
Tests: added absolute_redirect and Location tests for HTTP/2.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1731
diff
changeset
|
188 my $sid = $s->new_stream({ host => $host, path => $uri }); |
41ca4b00c2d0
Tests: added absolute_redirect and Location tests for HTTP/2.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1731
diff
changeset
|
189 my $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); |
41ca4b00c2d0
Tests: added absolute_redirect and Location tests for HTTP/2.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1731
diff
changeset
|
190 |
41ca4b00c2d0
Tests: added absolute_redirect and Location tests for HTTP/2.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1731
diff
changeset
|
191 my ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
41ca4b00c2d0
Tests: added absolute_redirect and Location tests for HTTP/2.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1731
diff
changeset
|
192 return 'Location: ' . $frame->{headers}->{'location'}; |
1103
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
193 } |
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
194 |
71bba21ea3ed
Tests: absolute_redirect and related tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
195 ############################################################################### |