Mercurial > hg > nginx-tests
annotate rewrite.t @ 1282:fd281e3a3df5
Tests: better test names in h2_server_push.t.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Mon, 12 Feb 2018 14:46:40 +0300 |
parents | 882267679006 |
children | 14bfd6643bbb |
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 | |
337
43d40a678a64
Tests: added rewrite test for response without reason phrase.
Sergey Kandaurov <pluknet@nginx.com>
parents:
249
diff
changeset
|
24 my $t = Test::Nginx->new()->has(qw/http rewrite/)->plan(22) |
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 } |
65 | 133 } |
134 } | |
135 | |
136 EOF | |
137 | |
141
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
138 mkdir($t->testdir() . '/directory'); |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
139 |
65 | 140 $t->run(); |
141 | |
142 ############################################################################### | |
143 | |
144 like(http_get('/'), qr!^Location: http://example.com/\x0d?$!ms, 'simple'); | |
145 like(http_get('/?a=b'), qr!^Location: http://example.com/\?a=b\x0d?$!ms, | |
146 'simple with args'); | |
147 like(http_get('/add'), qr!^Location: http://example.com/\?c=d\x0d?$!ms, | |
148 'add args'); | |
149 | |
150 like(http_get('/add?a=b'), qr!^Location: http://example.com/\?c=d&a=b\x0d?$!ms, | |
151 'add args with args'); | |
152 | |
153 like(http_get('/no?a=b'), qr!^Location: http://example.com/\?c=d\x0d?$!ms, | |
154 'no args with args'); | |
155 | |
141
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
156 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
|
157 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
|
158 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
|
159 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
|
160 |
d732aaa5f370
Tests: two more return/error_page tests, with builtin error pages.
Maxim Dounin <mdounin@mdounin.ru>
parents:
141
diff
changeset
|
161 like(http_get('/error404return405'), qr!HTTP/1.1 404!, 'error 404 return 405'); |
141
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
162 |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
163 # 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
|
164 # 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
|
165 # to make problem clear |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
166 |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
167 my $r = http(<<EOF); |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
168 GET /error405return204 HTTP/1.1 |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
169 Host: localhost |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
170 Connection: close |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
171 |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
172 EOF |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
173 |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
174 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
|
175 'error 405 return 204'); |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
176 |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
177 # 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
|
178 # 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
|
179 # in /error405return200text below) |
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 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
|
182 'error 405 return 200'); |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
183 |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
184 # 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
|
185 # 0.8.42 |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
186 |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
187 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
|
188 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
|
189 |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
190 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
|
191 '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
|
192 |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
193 # 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
|
194 # 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
|
195 # 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
|
196 |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
197 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
|
198 'return 302 text'); |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
199 |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
200 like(http_get('/error302return200text'), |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
201 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
|
202 'error 302 return 200 text'); |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
203 |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
204 # 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
|
205 # 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
|
206 # 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
|
207 |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
208 like(http_get('/error405return302text'), |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
209 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
|
210 'error 405 return 302 text'); |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
211 |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
212 like(http_get('/error405rewrite'), |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
213 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
|
214 'error 405 rewrite redirect'); |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
215 |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
216 like(http_get('/error405directory'), |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
217 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
|
218 'error 405 directory redirect'); |
1e1975cd25ef
Tests: error_page and return related tests, dav tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
121
diff
changeset
|
219 |
215
7f5095965c88
Tests: added rewrite tests for ticket #162.
Maxim Dounin <mdounin@mdounin.ru>
parents:
180
diff
changeset
|
220 # 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
|
221 # is actually calculated (ticket #162) |
7f5095965c88
Tests: added rewrite tests for ticket #162.
Maxim Dounin <mdounin@mdounin.ru>
parents:
180
diff
changeset
|
222 |
7f5095965c88
Tests: added rewrite tests for ticket #162.
Maxim Dounin <mdounin@mdounin.ru>
parents:
180
diff
changeset
|
223 like(http_get('/capture/%25?a=b'), |
7f5095965c88
Tests: added rewrite tests for ticket #162.
Maxim Dounin <mdounin@mdounin.ru>
parents:
180
diff
changeset
|
224 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
|
225 'escape with added args'); |
7f5095965c88
Tests: added rewrite tests for ticket #162.
Maxim Dounin <mdounin@mdounin.ru>
parents:
180
diff
changeset
|
226 |
7f5095965c88
Tests: added rewrite tests for ticket #162.
Maxim Dounin <mdounin@mdounin.ru>
parents:
180
diff
changeset
|
227 like(http_get('/capturedup/%25?a=b'), |
7f5095965c88
Tests: added rewrite tests for ticket #162.
Maxim Dounin <mdounin@mdounin.ru>
parents:
180
diff
changeset
|
228 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
|
229 'escape with added args'); |
7f5095965c88
Tests: added rewrite tests for ticket #162.
Maxim Dounin <mdounin@mdounin.ru>
parents:
180
diff
changeset
|
230 |
65 | 231 ############################################################################### |