comparison rewrite.t @ 215:7f5095965c88

Tests: added rewrite tests for ticket #162.
author Maxim Dounin <mdounin@mdounin.ru>
date Thu, 03 May 2012 14:48:30 +0400
parents 58ee6372aba0
children a01a53bcbf11
comparison
equal deleted inserted replaced
214:35d050d7d5f1 215:7f5095965c88
19 ############################################################################### 19 ###############################################################################
20 20
21 select STDERR; $| = 1; 21 select STDERR; $| = 1;
22 select STDOUT; $| = 1; 22 select STDOUT; $| = 1;
23 23
24 my $t = Test::Nginx->new()->has(qw/http rewrite/)->plan(19) 24 my $t = Test::Nginx->new()->has(qw/http rewrite/)->plan(21)
25 ->write_file_expand('nginx.conf', <<'EOF'); 25 ->write_file_expand('nginx.conf', <<'EOF');
26 26
27 %%TEST_GLOBALS%% 27 %%TEST_GLOBALS%%
28 28
29 daemon off; 29 daemon off;
113 error_page 405 /directory; 113 error_page 405 /directory;
114 return 405; 114 return 405;
115 } 115 }
116 116
117 location /directory { 117 location /directory {
118 }
119
120 location /capture {
121 rewrite ^(.*) $1?c=d;
122 return 200 "uri:$uri args:$args";
123 }
124
125 location /capturedup {
126 rewrite ^(.*) $1?c=$1;
127 return 200 "uri:$uri args:$args";
118 } 128 }
119 } 129 }
120 } 130 }
121 131
122 EOF 132 EOF
200 210
201 like(http_get('/error405directory'), 211 like(http_get('/error405directory'),
202 qr!HTTP/1.1 301.*Location: http://!ms, 212 qr!HTTP/1.1 301.*Location: http://!ms,
203 'error 405 directory redirect'); 213 'error 405 directory redirect');
204 214
205 ############################################################################### 215 # escaping of uri if there are args added in rewrite, and length
216 # is actually calculated (ticket #162)
217
218 like(http_get('/capture/%25?a=b'),
219 qr!^uri:/capture/% args:c=d&a=b$!ms,
220 'escape with added args');
221
222 TODO: {
223 local $TODO = 'patch pending';
224
225 like(http_get('/capturedup/%25?a=b'),
226 qr!^uri:/capturedup/% args:c=/capturedup/%25&a=b$!ms,
227 'escape with added args');
228
229 }
230
231 ###############################################################################