# HG changeset patch # User Maxim Dounin # Date 1254432390 -14400 # Node ID 6303927c18d2023887b77718d8fbb9a4bac99f94 # Parent 9ddc182148541171368919df8370e13ee86e06a9 Tests: proxy cache tests for problems with duplicate final chunks. diff --git a/proxy-cache.t b/proxy-cache.t --- a/proxy-cache.t +++ b/proxy-cache.t @@ -9,12 +9,12 @@ use warnings; use strict; -use Test::More tests => 7; +use Test::More tests => 9; BEGIN { use FindBin; chdir($FindBin::Bin); } use lib 'lib'; -use Test::Nginx; +use Test::Nginx qw/ :DEFAULT :gzip /; ############################################################################### @@ -46,18 +46,22 @@ http { listen 127.0.0.1:8080; server_name localhost; + gzip on; + gzip_min_length 0; + location / { proxy_pass http://127.0.0.1:8081; proxy_cache NAME; - proxy_cache_valid 200 302 1h; + proxy_cache_valid 200 302 1s; proxy_cache_valid 301 1d; proxy_cache_valid any 1m; proxy_cache_min_uses 1; - proxy_cache_use_stale error timeout invalid_header http_500; + proxy_cache_use_stale error timeout invalid_header http_500 + http_404; } } server { @@ -91,6 +95,17 @@ like(http_get('/empty.html'), qr/HTTP/, { local $TODO = 'not fixed yet'; like(http_get('/empty.html'), qr/HTTP/, 'empty get second'); + +sleep(2); +unlink $t->testdir() . '/t.html'; +like(http_gzip_request('/t.html'), + qr/HTTP.*1c\x0d\x0a.{28}\x0d\x0a0\x0d\x0a\x0d\x0a\z/s, + 'non-empty get stale'); } +unlink $t->testdir() . '/empty.html'; +like(http_gzip_request('/empty.html'), + qr/HTTP.*14\x0d\x0a.{20}\x0d\x0a0\x0d\x0a\x0d\x0a\z/s, + 'empty get stale'); + ###############################################################################