Mercurial > hg > ngx_http_gunzip_filter_module
comparison t/gunzip-perl.t @ 2:5fc44c8ba213
Gunzip: add test for replies from perl module.
This requires patched perl module to succeed, so now it's TODO.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Thu, 24 Dec 2009 18:17:40 +0300 |
parents | |
children | 7170c171150c |
comparison
equal
deleted
inserted
replaced
1:0dd7d109e56b | 2:5fc44c8ba213 |
---|---|
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('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 | |
72 { | |
73 local $TODO = 'requires patched perl module'; | |
74 | |
75 like(http_get('/'), qr/TEST/, 'perl response gunzipped'); | |
76 } | |
77 | |
78 ############################################################################### |