Mercurial > hg > nginx-tests
comparison gunzip_static.t @ 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 | bc1861122d0c |
children | 6a0d934950bc |
comparison
equal
deleted
inserted
replaced
237:90af19544dd2 | 238:96387f409880 |
---|---|
23 select STDOUT; $| = 1; | 23 select STDOUT; $| = 1; |
24 | 24 |
25 eval { require IO::Compress::Gzip; }; | 25 eval { require IO::Compress::Gzip; }; |
26 Test::More::plan(skip_all => "IO::Compress::Gzip not found") if $@; | 26 Test::More::plan(skip_all => "IO::Compress::Gzip not found") if $@; |
27 | 27 |
28 my $t = Test::Nginx->new()->has(qw/http gunzip proxy gzip_static/); | 28 my $t = Test::Nginx->new()->has(qw/http gunzip proxy gzip_static rewrite/); |
29 | 29 |
30 $t->write_file_expand('nginx.conf', <<'EOF'); | 30 $t->write_file_expand('nginx.conf', <<'EOF'); |
31 | 31 |
32 %%TEST_GLOBALS%% | 32 %%TEST_GLOBALS%% |
33 | 33 |
43 listen 127.0.0.1:8080; | 43 listen 127.0.0.1:8080; |
44 server_name localhost; | 44 server_name localhost; |
45 location / { | 45 location / { |
46 gunzip on; | 46 gunzip on; |
47 gzip_vary on; | 47 gzip_vary on; |
48 gzip_static always; | |
49 } | |
50 location = /double { | |
51 error_page 404 @double; | |
52 gzip_static on; | |
53 } | |
54 location @double { | |
55 rewrite ^ /t1 break; | |
56 gunzip on; | |
48 gzip_static always; | 57 gzip_static always; |
49 } | 58 } |
50 location /error { | 59 location /error { |
51 error_page 500 /t1; | 60 error_page 500 /t1; |
52 return 500; | 61 return 500; |
76 | 85 |
77 ############################################################################### | 86 ############################################################################### |
78 | 87 |
79 pass('runs'); | 88 pass('runs'); |
80 | 89 |
81 my $r = http_get('/t1'); | 90 like(http_get('/t1'), qr/(?!Content-Encoding).*^(X\d\d\dXXXXXX){100}$/m, |
82 unlike($r, qr/Content-Encoding/, 'no content encoding'); | 91 'correct gunzipped response'); |
83 like($r, qr/^(X\d\d\dXXXXXX){100}$/m, 'correct gunzipped response'); | 92 like(http_gzip_request('/t1'), qr/Content-Encoding: gzip.*\Q$out\E/ms, |
93 'gzip still works'); | |
84 | 94 |
85 $r = http_gzip_request('/t1'); | 95 like(http_get('/double'), qr/(?!Content-Encoding).^(X\d\d\dXXXXXX){100}$/ms, |
86 like($r, qr/Content-Encoding: gzip/, 'gzip still works - encoding'); | 96 'gunzip with gzip_tested'); |
87 like($r, qr/\Q$out\E/, 'gzip still works - content'); | 97 like(http_gzip_request('/double'), qr/Content-Encoding: gzip.*\Q$out\E/ms, |
98 'gzip still works with gzip_tested'); | |
88 | 99 |
89 like(http_get('/t2'), qr/^(X\d\d\dXXXXXX){200}$/m, 'multiple gzip members'); | 100 like(http_get('/t2'), qr/^(X\d\d\dXXXXXX){200}$/m, 'multiple gzip members'); |
90 | 101 |
91 like(http_get('/error'), qr/^(X\d\d\dXXXXXX){100}$/m, 'errors gunzipped'); | 102 like(http_get('/error'), qr/^(X\d\d\dXXXXXX){100}$/m, 'errors gunzipped'); |
92 | 103 |