# HG changeset patch # User Maxim Dounin # Date 1261667860 -10800 # Node ID 5fc44c8ba213e9feea9edd44091b052f6836a06b # Parent 0dd7d109e56b700705b427b03ee4591eb228e0e9 Gunzip: add test for replies from perl module. This requires patched perl module to succeed, so now it's TODO. diff --git a/t/gunzip-perl.t b/t/gunzip-perl.t new file mode 100644 --- /dev/null +++ b/t/gunzip-perl.t @@ -0,0 +1,78 @@ +#!/usr/bin/perl + +# (C) Maxim Dounin + +# Tests for gunzip filter module with perl module. + +############################################################################### + +use warnings; +use strict; + +use Test::More; + +BEGIN { use FindBin; chdir($FindBin::Bin); } + +use lib 'lib'; +use Test::Nginx qw/ :DEFAULT :gzip /; + +############################################################################### + +select STDERR; $| = 1; +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('perl')->plan(2) + ->write_file_expand('nginx.conf', <<'EOF'); + +%%TEST_GLOBALS%% + +master_process off; +daemon off; + +events { +} + +http { + %%TEST_GLOBALS_HTTP%% + + server { + listen 127.0.0.1:8080; + server_name localhost; + + gunzip on; + + location / { + perl 'sub { + my $r = shift; + $r->header_out("Content-Encoding", "gzip"); + $r->send_http_header("text/plain"); + return OK if $r->header_only; + use IO::Compress::Gzip; + my $in = "TEST"; + my $out; + IO::Compress::Gzip::gzip(\\$in => \\$out); + $r->print($out); + return OK; + }'; + } + } +} + +EOF + +$t->run(); + +############################################################################### + +http_gzip_like(http_gzip_request('/'), qr/TEST/, 'perl response gzipped'); + +{ +local $TODO = 'requires patched perl module'; + +like(http_get('/'), qr/TEST/, 'perl response gunzipped'); +} + +###############################################################################