Mercurial > hg > nginx-tests
comparison proxy_cache_vary.t @ 1590:e682d5ad3861
Tests: added two cache Vary cases fixed in 1.19.3.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Mon, 14 Sep 2020 22:27:59 +0100 |
parents | 196d33c2bb45 |
children | feb754918372 |
comparison
equal
deleted
inserted
replaced
1589:f145dce55f32 | 1590:e682d5ad3861 |
---|---|
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 rewrite/) | 24 my $t = Test::Nginx->new()->has(qw/http proxy cache gzip rewrite/) |
25 ->plan(42)->write_file_expand('nginx.conf', <<'EOF'); | 25 ->plan(49)->write_file_expand('nginx.conf', <<'EOF'); |
26 | 26 |
27 %%TEST_GLOBALS%% | 27 %%TEST_GLOBALS%% |
28 | 28 |
29 daemon off; | 29 daemon off; |
30 | 30 |
79 | 79 |
80 location / { | 80 location / { |
81 if ($args = "novary") { | 81 if ($args = "novary") { |
82 return 200 "the only variant\n"; | 82 return 200 "the only variant\n"; |
83 } | 83 } |
84 | |
85 add_header Vary $arg_vary; | |
86 add_header Xtra $arg_xtra; | |
84 } | 87 } |
85 | 88 |
86 location /asterisk { | 89 location /asterisk { |
87 gzip off; | 90 gzip off; |
88 add_header Vary "*"; | 91 add_header Vary "*"; |
246 | 249 |
247 like(get('/', 'bar,foo'), qr/HIT/ms, 'normalize order'); | 250 like(get('/', 'bar,foo'), qr/HIT/ms, 'normalize order'); |
248 | 251 |
249 } | 252 } |
250 | 253 |
254 # keep c->body_start when Vary changes (ticket #2029) | |
255 | |
256 # before 1.19.3, this prevented updating c->body_start of a main key | |
257 # triggering "cache file .. has too long header" critical errors | |
258 | |
259 like(get1('/?vary=x,y', 'x:1'), qr/MISS/, 'change first'); | |
260 | |
261 TODO: { | |
262 local $TODO = 'not yet' unless $t->has_version('1.19.3'); | |
263 | |
264 like(get1('/?vary=x,y', 'x:1'), qr/HIT/, 'change first cached'); | |
265 | |
266 } | |
267 | |
268 like(get1('/?vary=x,y&xtra=1', 'x:2'), qr/MISS/, 'change second'); | |
269 like(get1('/?vary=x,y&xtra=1', 'x:2'), qr/HIT/, 'change second cached'); | |
270 | |
271 $t->stop(); | |
272 $t->run(); | |
273 | |
274 # reset c->body_start when loading a secondary key variant | |
275 | |
276 # before 1.19.3, it was loaded using a variant stored with a main key | |
277 # triggering "cache file .. has too long header" critical errors | |
278 | |
279 like(get1('/?vary=x,y', 'x:1'), qr/HIT/, 'cold first'); | |
280 | |
281 TODO: { | |
282 local $TODO = 'not yet' unless $t->has_version('1.19.3'); | |
283 | |
284 like(get1('/?vary=x,y&xtra=1', 'x:2'), qr/HIT/, 'cold second'); | |
285 | |
286 } | |
287 | |
288 $t->stop(); | |
289 | |
290 TODO: { | |
291 local $TODO = 'not yet' unless $t->has_version('1.19.3'); | |
292 | |
293 like(`grep -F '[crit]' ${\($t->testdir())}/error.log`, qr/^$/s, 'no crit'); | |
294 | |
295 } | |
296 | |
251 ############################################################################### | 297 ############################################################################### |
252 | 298 |
253 sub get { | 299 sub get { |
254 my ($url, $extra) = @_; | 300 my ($url, $extra) = @_; |
255 return http(<<EOF); | 301 return http(<<EOF); |
259 Accept-Encoding: $extra | 305 Accept-Encoding: $extra |
260 | 306 |
261 EOF | 307 EOF |
262 } | 308 } |
263 | 309 |
264 ############################################################################### | 310 sub get1 { |
311 my ($url, $extra) = @_; | |
312 return http(<<EOF); | |
313 GET $url HTTP/1.1 | |
314 Host: localhost | |
315 Connection: close | |
316 $extra | |
317 | |
318 EOF | |
319 } | |
320 | |
321 ############################################################################### |