Mercurial > hg > nginx-tests
annotate rewrite.t @ 1990:85d88cd5091c
Tests: SSI include stub tests.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Thu, 04 Jul 2024 17:42:55 +0300 |
parents | 5ac6efbe5552 |
children |
rev | line source |
---|---|
65 | 1 #!/usr/bin/perl |
2 | |
3 # (C) Maxim Dounin | |
4 | |
5 # Tests for rewrite module. | |
6 | |
7 ############################################################################### | |
8 | |
9 use warnings; | |
10 use strict; | |
11 | |
12 use Test::More; | |
13 | |
14 BEGIN { use FindBin; chdir($FindBin::Bin); } | |
15 | |
16 use lib 'lib'; | |
17 use Test::Nginx; | |
18 | |
19 ############################################################################### | |
20 | |
21 select STDERR; $| = 1; | |
22 select STDOUT; $| = 1; | |
23 | |
1546
0902a4539c99
Tests: added rewrite "break" directive test for valid location.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
24 my $t = Test::Nginx->new()->has(qw/http rewrite proxy/)->plan(23) |
65 | 25 ->write_file_expand('nginx.conf', <<'EOF'); |
26 | |
107
1c0ec30614c6
Tests: add TEST_GLOBALS and TEST_GLOBALS_HTTP config chunks.
Maxim Dounin <mdounin@mdounin.ru>
parents:
70
diff
changeset
|
27 %%TEST_GLOBALS%% |
1c0ec30614c6
Tests: add TEST_GLOBALS and TEST_GLOBALS_HTTP config chunks.
Maxim Dounin <mdounin@mdounin.ru>
parents:
70
diff
changeset
|
28 |
249
6a0d934950bc
Tests: remove extra spaces in "daemon off".
Maxim Dounin <mdounin@mdounin.ru>
parents:
241
diff
changeset
|
29 daemon off; |
65 | 30 |
31 events { | |
32 } | |
33 | |
34 http { | |
107
1c0ec30614c6
Tests: add TEST_GLOBALS and TEST_GLOBALS_HTTP config chunks.
Maxim Dounin <mdounin@mdounin.ru>
parents:
70
diff
changeset
|
35 %%TEST_GLOBALS_HTTP%% |
65 | 36 |
37 server { | |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
38 listen 127.0.0.1:8080; |
65 | 39 server_name localhost; |
40 | |
41 location / { | |
42 rewrite ^ http://example.com/ redirect; | |
43 } | |
44 | |
45 location /add { | |
46 rewrite ^ http://example.com/?c=d redirect; | |
47 } | |
48 | |
49 location /no { | |
50 rewrite ^ http://example.com/?c=d? redirect; | |
51 } | |
141
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
52 |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
53 location /return204 { |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
54 return 204; |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
55 } |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
56 |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
57 location /return200 { |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
58 return 200; |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
59 } |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
60 |
337
43d40a678a64
Tests: added rewrite test for response without reason phrase.
Sergey Kandaurov <pluknet@nginx.com>
parents:
249
diff
changeset
|
61 location /return306 { |
43d40a678a64
Tests: added rewrite test for response without reason phrase.
Sergey Kandaurov <pluknet@nginx.com>
parents:
249
diff
changeset
|
62 return 306; |
43d40a678a64
Tests: added rewrite test for response without reason phrase.
Sergey Kandaurov <pluknet@nginx.com>
parents:
249
diff
changeset
|
63 } |
43d40a678a64
Tests: added rewrite test for response without reason phrase.
Sergey Kandaurov <pluknet@nginx.com>
parents:
249
diff
changeset
|
64 |
142
d732aaa5f370
Tests: two more return/error_page tests, with builtin error pages.
Maxim Dounin <mdounin@mdounin.ru>
parents:
141
diff
changeset
|
65 location /return405 { |
d732aaa5f370
Tests: two more return/error_page tests, with builtin error pages.
Maxim Dounin <mdounin@mdounin.ru>
parents:
141
diff
changeset
|
66 return 405; |
d732aaa5f370
Tests: two more return/error_page tests, with builtin error pages.
Maxim Dounin <mdounin@mdounin.ru>
parents:
141
diff
changeset
|
67 } |
d732aaa5f370
Tests: two more return/error_page tests, with builtin error pages.
Maxim Dounin <mdounin@mdounin.ru>
parents:
141
diff
changeset
|
68 |
d732aaa5f370
Tests: two more return/error_page tests, with builtin error pages.
Maxim Dounin <mdounin@mdounin.ru>
parents:
141
diff
changeset
|
69 location /error404return405 { |
d732aaa5f370
Tests: two more return/error_page tests, with builtin error pages.
Maxim Dounin <mdounin@mdounin.ru>
parents:
141
diff
changeset
|
70 error_page 404 /return405; |
d732aaa5f370
Tests: two more return/error_page tests, with builtin error pages.
Maxim Dounin <mdounin@mdounin.ru>
parents:
141
diff
changeset
|
71 return 404; |
d732aaa5f370
Tests: two more return/error_page tests, with builtin error pages.
Maxim Dounin <mdounin@mdounin.ru>
parents:
141
diff
changeset
|
72 } |
d732aaa5f370
Tests: two more return/error_page tests, with builtin error pages.
Maxim Dounin <mdounin@mdounin.ru>
parents:
141
diff
changeset
|
73 |
141
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
74 location /error405return204 { |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
75 error_page 405 /return204; |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
76 return 405; |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
77 } |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
78 |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
79 location /error405return200 { |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
80 error_page 405 /return200; |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
81 return 405; |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
82 } |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
83 |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
84 location /return200text { |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
85 return 200 "text"; |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
86 } |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
87 |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
88 location /return404text { |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
89 return 404 "text"; |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
90 } |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
91 |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
92 location /return302text { |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
93 return 302 "text"; |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
94 } |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
95 |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
96 location /error405return200text { |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
97 error_page 405 /return200text; |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
98 return 405; |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
99 } |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
100 |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
101 location /error302return200text { |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
102 error_page 302 /return200text; |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
103 return 302 "text"; |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
104 } |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
105 |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
106 location /error405return302text { |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
107 error_page 405 /return302text; |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
108 return 405; |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
109 } |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
110 |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
111 location /error405rewrite { |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
112 error_page 405 /; |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
113 return 405; |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
114 } |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
115 |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
116 location /error405directory { |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
117 error_page 405 /directory; |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
118 return 405; |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
119 } |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
120 |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
121 location /directory { |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
122 } |
215
7f5095965c88
Tests: added rewrite tests for ticket #162.
Maxim Dounin <mdounin@mdounin.ru>
parents:
180
diff
changeset
|
123 |
7f5095965c88
Tests: added rewrite tests for ticket #162.
Maxim Dounin <mdounin@mdounin.ru>
parents:
180
diff
changeset
|
124 location /capture { |
7f5095965c88
Tests: added rewrite tests for ticket #162.
Maxim Dounin <mdounin@mdounin.ru>
parents:
180
diff
changeset
|
125 rewrite ^(.*) $1?c=d; |
7f5095965c88
Tests: added rewrite tests for ticket #162.
Maxim Dounin <mdounin@mdounin.ru>
parents:
180
diff
changeset
|
126 return 200 "uri:$uri args:$args"; |
7f5095965c88
Tests: added rewrite tests for ticket #162.
Maxim Dounin <mdounin@mdounin.ru>
parents:
180
diff
changeset
|
127 } |
7f5095965c88
Tests: added rewrite tests for ticket #162.
Maxim Dounin <mdounin@mdounin.ru>
parents:
180
diff
changeset
|
128 |
7f5095965c88
Tests: added rewrite tests for ticket #162.
Maxim Dounin <mdounin@mdounin.ru>
parents:
180
diff
changeset
|
129 location /capturedup { |
7f5095965c88
Tests: added rewrite tests for ticket #162.
Maxim Dounin <mdounin@mdounin.ru>
parents:
180
diff
changeset
|
130 rewrite ^(.*) $1?c=$1; |
7f5095965c88
Tests: added rewrite tests for ticket #162.
Maxim Dounin <mdounin@mdounin.ru>
parents:
180
diff
changeset
|
131 return 200 "uri:$uri args:$args"; |
7f5095965c88
Tests: added rewrite tests for ticket #162.
Maxim Dounin <mdounin@mdounin.ru>
parents:
180
diff
changeset
|
132 } |
1546
0902a4539c99
Tests: added rewrite "break" directive test for valid location.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
133 |
0902a4539c99
Tests: added rewrite "break" directive test for valid location.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
134 location /break { |
0902a4539c99
Tests: added rewrite "break" directive test for valid location.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
135 rewrite ^ /return200; |
0902a4539c99
Tests: added rewrite "break" directive test for valid location.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
136 break; |
0902a4539c99
Tests: added rewrite "break" directive test for valid location.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
137 proxy_pass http://127.0.0.1:8080/return204; |
0902a4539c99
Tests: added rewrite "break" directive test for valid location.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
138 } |
65 | 139 } |
140 } | |
141 | |
142 EOF | |
143 | |
141
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
144 mkdir($t->testdir() . '/directory'); |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
145 |
65 | 146 $t->run(); |
147 | |
148 ############################################################################### | |
149 | |
150 like(http_get('/'), qr!^Location: http://example.com/\x0d?$!ms, 'simple'); | |
151 like(http_get('/?a=b'), qr!^Location: http://example.com/\?a=b\x0d?$!ms, | |
152 'simple with args'); | |
153 like(http_get('/add'), qr!^Location: http://example.com/\?c=d\x0d?$!ms, | |
154 'add args'); | |
155 | |
156 like(http_get('/add?a=b'), qr!^Location: http://example.com/\?c=d&a=b\x0d?$!ms, | |
157 'add args with args'); | |
158 | |
159 like(http_get('/no?a=b'), qr!^Location: http://example.com/\?c=d\x0d?$!ms, | |
160 'no args with args'); | |
161 | |
141
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
162 like(http_get('/return204'), qr!204 No Content!, 'return 204'); |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
163 like(http_get('/return200'), qr!200 OK!, 'return 200'); |
337
43d40a678a64
Tests: added rewrite test for response without reason phrase.
Sergey Kandaurov <pluknet@nginx.com>
parents:
249
diff
changeset
|
164 like(http_get('/return306'), qr!HTTP/1.1 306 !, 'return 306'); |
142
d732aaa5f370
Tests: two more return/error_page tests, with builtin error pages.
Maxim Dounin <mdounin@mdounin.ru>
parents:
141
diff
changeset
|
165 like(http_get('/return405'), qr!HTTP/1.1 405.*body!ms, 'return 405'); |
d732aaa5f370
Tests: two more return/error_page tests, with builtin error pages.
Maxim Dounin <mdounin@mdounin.ru>
parents:
141
diff
changeset
|
166 |
1379
14bfd6643bbb
Tests: updated rewrite.t for the return r->err_status change.
Maxim Dounin <mdounin@mdounin.ru>
parents:
974
diff
changeset
|
167 # this used to result in 404, but was changed in 1.15.4 |
14bfd6643bbb
Tests: updated rewrite.t for the return r->err_status change.
Maxim Dounin <mdounin@mdounin.ru>
parents:
974
diff
changeset
|
168 # to respond with 405 instead, much like a real error would do |
14bfd6643bbb
Tests: updated rewrite.t for the return r->err_status change.
Maxim Dounin <mdounin@mdounin.ru>
parents:
974
diff
changeset
|
169 |
14bfd6643bbb
Tests: updated rewrite.t for the return r->err_status change.
Maxim Dounin <mdounin@mdounin.ru>
parents:
974
diff
changeset
|
170 like(http_get('/error404return405'), qr!HTTP/1.1 405!, 'error 404 return 405'); |
14bfd6643bbb
Tests: updated rewrite.t for the return r->err_status change.
Maxim Dounin <mdounin@mdounin.ru>
parents:
974
diff
changeset
|
171 |
141
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
172 # status code should be 405, and entity body is expected (vs. normal 204 |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
173 # replies which doesn't expect to have body); use HTTP/1.1 for test |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
174 # to make problem clear |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
175 |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
176 my $r = http(<<EOF); |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
177 GET /error405return204 HTTP/1.1 |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
178 Host: localhost |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
179 Connection: close |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
180 |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
181 EOF |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
182 |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
183 like($r, qr/HTTP\/1.1 405.*(Content-Length|\x0d\0a0\x0d\x0a)/ms, |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
184 'error 405 return 204'); |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
185 |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
186 # the same test, but with return 200. this doesn't have special |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
187 # handling and returns builtin error page body (the same problem as |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
188 # in /error405return200text below) |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
189 |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
190 like(http_get('/error405return200'), qr/HTTP\/1.1 405(?!.*body)/ms, |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
191 'error 405 return 200'); |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
192 |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
193 # tests involving return with two arguments, as introduced in |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
194 # 0.8.42 |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
195 |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
196 like(http_get('/return200text'), qr!text\z!, 'return 200 text'); |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
197 like(http_get('/return404text'), qr!text\z!, 'return 404 text'); |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
198 |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
199 like(http_get('/error405return200text'), qr!HTTP/1.1 405.*text\z!ms, |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
200 'error 405 to return 200 text'); |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
201 |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
202 # return 302 is somewhat special: it adds Location header instead of |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
203 # body text. additionally it doesn't sent reply directly (as it's done for |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
204 # other returns since 0.8.42) but instead returns NGX_HTTP_* code |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
205 |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
206 like(http_get('/return302text'), qr!HTTP/1.1 302.*Location: text!ms, |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
207 'return 302 text'); |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
208 |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
209 like(http_get('/error302return200text'), |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
210 qr!HTTP/1.1 302.*Location: text.*text\z!ms, |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
211 'error 302 return 200 text'); |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
212 |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
213 # in contrast to other return's this shouldn't preserve original status code |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
214 # from error, and the same applies to "rewrite ... redirect" as an error |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
215 # handler; both should in line with e.g. directory redirect as well |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
216 |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
217 like(http_get('/error405return302text'), |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
218 qr!HTTP/1.1 302.*Location: text!ms, |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
219 'error 405 return 302 text'); |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
220 |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
221 like(http_get('/error405rewrite'), |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
222 qr!HTTP/1.1 302.*Location: http://example.com/!ms, |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
223 'error 405 rewrite redirect'); |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
224 |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
225 like(http_get('/error405directory'), |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
226 qr!HTTP/1.1 301.*Location: http://!ms, |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
227 'error 405 directory redirect'); |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
228 |
215
7f5095965c88
Tests: added rewrite tests for ticket #162.
Maxim Dounin <mdounin@mdounin.ru>
parents:
180
diff
changeset
|
229 # escaping of uri if there are args added in rewrite, and length |
7f5095965c88
Tests: added rewrite tests for ticket #162.
Maxim Dounin <mdounin@mdounin.ru>
parents:
180
diff
changeset
|
230 # is actually calculated (ticket #162) |
7f5095965c88
Tests: added rewrite tests for ticket #162.
Maxim Dounin <mdounin@mdounin.ru>
parents:
180
diff
changeset
|
231 |
7f5095965c88
Tests: added rewrite tests for ticket #162.
Maxim Dounin <mdounin@mdounin.ru>
parents:
180
diff
changeset
|
232 like(http_get('/capture/%25?a=b'), |
7f5095965c88
Tests: added rewrite tests for ticket #162.
Maxim Dounin <mdounin@mdounin.ru>
parents:
180
diff
changeset
|
233 qr!^uri:/capture/% args:c=d&a=b$!ms, |
7f5095965c88
Tests: added rewrite tests for ticket #162.
Maxim Dounin <mdounin@mdounin.ru>
parents:
180
diff
changeset
|
234 'escape with added args'); |
7f5095965c88
Tests: added rewrite tests for ticket #162.
Maxim Dounin <mdounin@mdounin.ru>
parents:
180
diff
changeset
|
235 |
7f5095965c88
Tests: added rewrite tests for ticket #162.
Maxim Dounin <mdounin@mdounin.ru>
parents:
180
diff
changeset
|
236 like(http_get('/capturedup/%25?a=b'), |
7f5095965c88
Tests: added rewrite tests for ticket #162.
Maxim Dounin <mdounin@mdounin.ru>
parents:
180
diff
changeset
|
237 qr!^uri:/capturedup/% args:c=/capturedup/%25&a=b$!ms, |
7f5095965c88
Tests: added rewrite tests for ticket #162.
Maxim Dounin <mdounin@mdounin.ru>
parents:
180
diff
changeset
|
238 'escape with added args'); |
7f5095965c88
Tests: added rewrite tests for ticket #162.
Maxim Dounin <mdounin@mdounin.ru>
parents:
180
diff
changeset
|
239 |
1546
0902a4539c99
Tests: added rewrite "break" directive test for valid location.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
240 # break |
0902a4539c99
Tests: added rewrite "break" directive test for valid location.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
241 |
0902a4539c99
Tests: added rewrite "break" directive test for valid location.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
242 like(http_get('/break'), qr/200/, 'valid_location reset'); |
0902a4539c99
Tests: added rewrite "break" directive test for valid location.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1535
diff
changeset
|
243 |
65 | 244 ############################################################################### |