comparison http_location.t @ 335:433be52171d5

Tests: more location matching tests.
author Maxim Dounin <mdounin@mdounin.ru>
date Tue, 17 Sep 2013 05:52:54 +0400
parents 98c6af2a5138
children b86d60e4cb96
comparison
equal deleted inserted replaced
334:c0bd624db067 335:433be52171d5
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(10) 24 my $t = Test::Nginx->new()->has(qw/http rewrite/)->plan(14)
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;
61 location ~ casefull { 61 location ~ casefull {
62 add_header X-Location casefull; 62 add_header X-Location casefull;
63 return 204; 63 return 204;
64 } 64 }
65 65
66 location = /foo {
67 add_header X-Location "/foo exact";
68 return 204;
69 }
70
71 location /foo {
72 add_header X-Location "/foo prefix";
73 return 204;
74 }
75
76 location = /foo/ {
77 add_header X-Location "/foo/ exact";
78 return 204;
79 }
80
81 location /foo/ {
82 add_header X-Location "/foo/ prefix";
83 return 204;
84 }
85
66 location /lowercase { 86 location /lowercase {
67 add_header X-Location lowercase; 87 add_header X-Location lowercase;
68 return 204; 88 return 204;
69 } 89 }
70 90
87 like(http_get('/t.gif'), qr/X-Location: regex/, 'regex'); 107 like(http_get('/t.gif'), qr/X-Location: regex/, 'regex');
88 like(http_get('/t.GIF'), qr/X-Location: regex/, 'regex with mungled case'); 108 like(http_get('/t.GIF'), qr/X-Location: regex/, 'regex with mungled case');
89 like(http_get('/casefull/t.gif'), qr/X-Location: regex/, 'first regex wins'); 109 like(http_get('/casefull/t.gif'), qr/X-Location: regex/, 'first regex wins');
90 like(http_get('/casefull/'), qr/X-Location: casefull/, 'casefull regex'); 110 like(http_get('/casefull/'), qr/X-Location: casefull/, 'casefull regex');
91 111
112 like(http_get('/foo'), qr!X-Location: /foo exact!, '/foo exact');
113 like(http_get('/foobar'), qr!X-Location: /foo prefix!, '/foo prefix');
114 like(http_get('/foo/'), qr!X-Location: /foo/ exact!, '/foo/ exact');
115 like(http_get('/foo/bar'), qr!X-Location: /foo/ prefix!, '/foo/ prefix');
116
92 SKIP: { 117 SKIP: {
93 skip 'caseless os', 1 118 skip 'caseless os', 1
94 if $^O eq 'MSWin32' or $^O eq 'darwin'; 119 if $^O eq 'MSWin32' or $^O eq 'darwin';
95 120
96 like(http_get('/CASEFULL/'), qr/X-Location: root/, 121 like(http_get('/CASEFULL/'), qr/X-Location: root/,