Mercurial > hg > nginx-tests
comparison proxy-cache.t @ 145:2ea7cd95ff05
Tests: basic tests for range requests from cache.
Just to prevent regressions while getting rid of r->cache dependency
in range filter.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Wed, 19 Jan 2011 06:20:11 +0300 |
parents | 3f246a1be2b0 |
children |
comparison
equal
deleted
inserted
replaced
144:6e11354cae8a | 145:2ea7cd95ff05 |
---|---|
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 proxy cache gzip/)->plan(10) | 24 my $t = Test::Nginx->new()->has(qw/http proxy cache gzip/)->plan(12) |
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 master_process off; | 29 master_process off; |
91 | 91 |
92 unlike(http_head('/t2.html'), qr/SEE-THIS/, 'head request'); | 92 unlike(http_head('/t2.html'), qr/SEE-THIS/, 'head request'); |
93 like(http_get('/t2.html'), qr/SEE-THIS/, 'get after head'); | 93 like(http_get('/t2.html'), qr/SEE-THIS/, 'get after head'); |
94 unlike(http_head('/t2.html'), qr/SEE-THIS/, 'head after get'); | 94 unlike(http_head('/t2.html'), qr/SEE-THIS/, 'head after get'); |
95 | 95 |
96 like(http_get_range('/t.html', 'Range: bytes=4-'), qr/^THIS/m, 'cached range'); | |
97 like(http_get_range('/t.html', 'Range: bytes=0-2,4-'), qr/^SEE.*^THIS/ms, | |
98 'cached multipart range'); | |
99 | |
96 like(http_get('/empty.html'), qr/HTTP/, 'empty get first'); | 100 like(http_get('/empty.html'), qr/HTTP/, 'empty get first'); |
97 like(http_get('/empty.html'), qr/HTTP/, 'empty get second'); | 101 like(http_get('/empty.html'), qr/HTTP/, 'empty get second'); |
98 | 102 |
99 { | 103 { |
100 local $TODO = 'not fixed yet'; | 104 local $TODO = 'not fixed yet'; |
118 { | 122 { |
119 local $TODO = 'patch pending'; | 123 local $TODO = 'patch pending'; |
120 | 124 |
121 http_get('/fake/unfinished'); | 125 http_get('/fake/unfinished'); |
122 like(http_get('/fake/unfinished'), qr/unfinished 2/, 'unfinished not cached'); | 126 like(http_get('/fake/unfinished'), qr/unfinished 2/, 'unfinished not cached'); |
127 } | |
128 | |
129 ############################################################################### | |
130 | |
131 sub http_get_range { | |
132 my ($url, $extra) = @_; | |
133 return http(<<EOF); | |
134 GET $url HTTP/1.1 | |
135 Host: localhost | |
136 Connection: close | |
137 $extra | |
138 | |
139 EOF | |
123 } | 140 } |
124 | 141 |
125 ############################################################################### | 142 ############################################################################### |
126 | 143 |
127 sub http_fake_daemon { | 144 sub http_fake_daemon { |