changeset 238:96387f409880

Tests: tests to catch incorrect r->gzip_ok check in gunzip.
author Maxim Dounin <mdounin@mdounin.ru>
date Thu, 18 Oct 2012 18:21:15 +0400
parents 90af19544dd2
children 5d178e27037c
files gunzip_static.t
diffstat 1 files changed, 18 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- 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');