comparison t/gunzip.t @ 1:0dd7d109e56b

Gunzip: add more tests and improve docs.
author Maxim Dounin <mdounin@mdounin.ru>
date Sun, 20 Dec 2009 03:55:31 +0300
parents a75d4ad9c5d2
children 7170c171150c
comparison
equal deleted inserted replaced
0:a75d4ad9c5d2 1:0dd7d109e56b
8 8
9 use warnings; 9 use warnings;
10 use strict; 10 use strict;
11 11
12 use Test::More; 12 use Test::More;
13 use Test::Nginx; 13 use Test::Nginx qw/ :DEFAULT :gzip /;
14 14
15 ############################################################################### 15 ###############################################################################
16 16
17 select STDERR; $| = 1; 17 select STDERR; $| = 1;
18 select STDOUT; $| = 1; 18 select STDOUT; $| = 1;
19 19
20 eval { require IO::Compress::Gzip; }; 20 eval { require IO::Compress::Gzip; };
21 Test::More::plan(skip_all => "IO::Compress::Gzip not found") if $@; 21 Test::More::plan(skip_all => "IO::Compress::Gzip not found") if $@;
22 22
23 my $t = Test::Nginx->new()->has('--with-http_gzip_static_module')->plan(10); 23 my $t = Test::Nginx->new()->has('--with-http_gzip_static_module')->plan(12);
24 24
25 $t->write_file_expand('nginx.conf', <<'EOF'); 25 $t->write_file_expand('nginx.conf', <<'EOF');
26 26
27 master_process off; 27 master_process off;
28 daemon off; 28 daemon off;
81 81
82 ############################################################################### 82 ###############################################################################
83 83
84 pass('runs'); 84 pass('runs');
85 85
86 my $t1 = http_get('/t1'); 86 my $r = http_get('/t1');
87 unlike($t1, qr/Content-Encoding/, 'no content encoding'); 87 unlike($r, qr/Content-Encoding/, 'no content encoding');
88 like($t1, qr/^(X\d\d\dXXXXXX){100}$/m, 'correct ungzipped response'); 88 like($r, qr/^(X\d\d\dXXXXXX){100}$/m, 'correct gunzipped response');
89
90 $r = http_gzip_request('/t1');
91 like($r, qr/Content-Encoding: gzip/, 'gzip still works - encoding');
92 like($r, qr/\Q$out\E/, 'gzip still works - content');
89 93
90 like(http_get('/t2'), qr/^(X\d\d\dXXXXXX){200}$/m, 'multiple gzip members'); 94 like(http_get('/t2'), qr/^(X\d\d\dXXXXXX){200}$/m, 'multiple gzip members');
91 95
92 like(http_get('/error'), qr/^(X\d\d\dXXXXXX){100}$/m, 'errors ungzipped'); 96 like(http_get('/error'), qr/^(X\d\d\dXXXXXX){100}$/m, 'errors gunzipped');
93 97
94 unlike(http_head('/t1'), qr/Content-Encoding/, 'head - no content encoding'); 98 unlike(http_head('/t1'), qr/Content-Encoding/, 'head - no content encoding');
95 99
96 like(http_get('/t1'), qr/Vary/, 'get vary'); 100 like(http_get('/t1'), qr/Vary/, 'get vary');
97 like(http_head('/t1'), qr/Vary/, 'head vary'); 101 like(http_head('/t1'), qr/Vary/, 'head vary');