# HG changeset patch # User Maxim Dounin # Date 1350570075 -14400 # Node ID 96387f409880e36c04733da13b6c0f28a86e8820 # Parent 90af19544dd232c76f28020babe38d4fc0a27a80 Tests: tests to catch incorrect r->gzip_ok check in gunzip. diff --git a/gunzip_static.t b/gunzip_static.t --- a/gunzip_static.t +++ b/gunzip_static.t @@ -25,7 +25,7 @@ select STDOUT; $| = 1; eval { require IO::Compress::Gzip; }; Test::More::plan(skip_all => "IO::Compress::Gzip not found") if $@; -my $t = Test::Nginx->new()->has(qw/http gunzip proxy gzip_static/); +my $t = Test::Nginx->new()->has(qw/http gunzip proxy gzip_static rewrite/); $t->write_file_expand('nginx.conf', <<'EOF'); @@ -47,6 +47,15 @@ http { gzip_vary on; gzip_static always; } + location = /double { + error_page 404 @double; + gzip_static on; + } + location @double { + rewrite ^ /t1 break; + gunzip on; + gzip_static always; + } location /error { error_page 500 /t1; return 500; @@ -78,13 +87,15 @@ plan(skip_all => 'no gzip_static always' pass('runs'); -my $r = http_get('/t1'); -unlike($r, qr/Content-Encoding/, 'no content encoding'); -like($r, qr/^(X\d\d\dXXXXXX){100}$/m, 'correct gunzipped response'); +like(http_get('/t1'), qr/(?!Content-Encoding).*^(X\d\d\dXXXXXX){100}$/m, + 'correct gunzipped response'); +like(http_gzip_request('/t1'), qr/Content-Encoding: gzip.*\Q$out\E/ms, + 'gzip still works'); -$r = http_gzip_request('/t1'); -like($r, qr/Content-Encoding: gzip/, 'gzip still works - encoding'); -like($r, qr/\Q$out\E/, 'gzip still works - content'); +like(http_get('/double'), qr/(?!Content-Encoding).^(X\d\d\dXXXXXX){100}$/ms, + 'gunzip with gzip_tested'); +like(http_gzip_request('/double'), qr/Content-Encoding: gzip.*\Q$out\E/ms, + 'gzip still works with gzip_tested'); like(http_get('/t2'), qr/^(X\d\d\dXXXXXX){200}$/m, 'multiple gzip members');