Mercurial > hg > ngx_http_gunzip_filter_module
comparison t/gunzip_perl.t @ 20:1adc6718cc05 draft
Gunzip: rename tests for better sorting.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Fri, 07 Sep 2012 19:27:41 +0400 |
parents | t/gunzip-perl.t@9d299b9f877b |
children | c0301992025a |
comparison
equal
deleted
inserted
replaced
19:9d299b9f877b | 20:1adc6718cc05 |
---|---|
1 #!/usr/bin/perl | |
2 | |
3 # (C) Maxim Dounin | |
4 | |
5 # Tests for gunzip filter module with perl module. | |
6 | |
7 ############################################################################### | |
8 | |
9 use warnings; | |
10 use strict; | |
11 | |
12 use Test::More; | |
13 | |
14 BEGIN { use FindBin; chdir($FindBin::Bin); } | |
15 | |
16 use lib 'lib'; | |
17 use Test::Nginx qw/ :DEFAULT :gzip /; | |
18 | |
19 ############################################################################### | |
20 | |
21 select STDERR; $| = 1; | |
22 select STDOUT; $| = 1; | |
23 | |
24 eval { require IO::Compress::Gzip; }; | |
25 Test::More::plan(skip_all => "IO::Compress::Gzip not found") if $@; | |
26 | |
27 my $t = Test::Nginx->new()->has(qw/http perl/)->plan(2) | |
28 ->write_file_expand('nginx.conf', <<'EOF'); | |
29 | |
30 %%TEST_GLOBALS%% | |
31 | |
32 master_process off; | |
33 daemon off; | |
34 | |
35 events { | |
36 } | |
37 | |
38 http { | |
39 %%TEST_GLOBALS_HTTP%% | |
40 | |
41 server { | |
42 listen 127.0.0.1:8080; | |
43 server_name localhost; | |
44 | |
45 gunzip on; | |
46 | |
47 location / { | |
48 perl 'sub { | |
49 my $r = shift; | |
50 $r->header_out("Content-Encoding", "gzip"); | |
51 $r->send_http_header("text/plain"); | |
52 return OK if $r->header_only; | |
53 use IO::Compress::Gzip; | |
54 my $in = "TEST"; | |
55 my $out; | |
56 IO::Compress::Gzip::gzip(\\$in => \\$out); | |
57 $r->print($out); | |
58 return OK; | |
59 }'; | |
60 } | |
61 } | |
62 } | |
63 | |
64 EOF | |
65 | |
66 $t->run(); | |
67 | |
68 ############################################################################### | |
69 | |
70 http_gzip_like(http_gzip_request('/'), qr/TEST/, 'perl response gzipped'); | |
71 like(http_get('/'), qr/TEST/, 'perl response gunzipped'); | |
72 | |
73 ############################################################################### |