Mercurial > hg > nginx-tests
annotate gunzip_perl.t @ 1606:e4e0695552ed
Tests: fixed stream_proxy_ssl_conf_command.t.
The stream_proxy_ssl_conf_command.t test used stream return module
to return the response. Since this ignores actual request, but the
perl test code used http_get(). This might result in the request being
sent after the response is returned and the connection closed by the server,
resulting in RST being generated and no response seen by the client at all.
Fix is to use "stream(...)->read()" instead of http_get(), so
no request is sent at all, eliminating possibility of RST being
generated.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Tue, 10 Nov 2020 05:03:29 +0300 |
parents | 882267679006 |
children |
rev | line source |
---|---|
231
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
2 |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
3 # (C) Maxim Dounin |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
4 |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
5 # Tests for gunzip filter module with perl module. |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
6 |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
7 ############################################################################### |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
8 |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
9 use warnings; |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
10 use strict; |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
11 |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
12 use Test::More; |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
13 |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
14 BEGIN { use FindBin; chdir($FindBin::Bin); } |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
15 |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
16 use lib 'lib'; |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
17 use Test::Nginx qw/ :DEFAULT :gzip /; |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
18 |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
19 ############################################################################### |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
20 |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
21 select STDERR; $| = 1; |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
22 select STDOUT; $| = 1; |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
23 |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
24 eval { require IO::Compress::Gzip; }; |
773 | 25 plan(skip_all => "IO::Compress::Gzip not found") if $@; |
231
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
26 |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
27 my $t = Test::Nginx->new()->has(qw/http gunzip perl/)->plan(2) |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
28 ->write_file_expand('nginx.conf', <<'EOF'); |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
29 |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
30 %%TEST_GLOBALS%% |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
31 |
249
6a0d934950bc
Tests: remove extra spaces in "daemon off".
Maxim Dounin <mdounin@mdounin.ru>
parents:
231
diff
changeset
|
32 daemon off; |
231
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
33 |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
34 events { |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
35 } |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
36 |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
37 http { |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
38 %%TEST_GLOBALS_HTTP%% |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
39 |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
40 server { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
41 listen 127.0.0.1:8080; |
231
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
42 server_name localhost; |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
43 |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
44 gunzip on; |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
45 |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
46 location / { |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
47 perl 'sub { |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
48 my $r = shift; |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
49 $r->header_out("Content-Encoding", "gzip"); |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
50 $r->send_http_header("text/plain"); |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
51 return OK if $r->header_only; |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
52 use IO::Compress::Gzip; |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
53 my $in = "TEST"; |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
54 my $out; |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
55 IO::Compress::Gzip::gzip(\\$in => \\$out); |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
56 $r->print($out); |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
57 return OK; |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
58 }'; |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
59 } |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
60 } |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
61 } |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
62 |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
63 EOF |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
64 |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
65 $t->run(); |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
66 |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
67 ############################################################################### |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
68 |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
69 http_gzip_like(http_gzip_request('/'), qr/TEST/, 'perl response gzipped'); |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
70 like(http_get('/'), qr/TEST/, 'perl response gunzipped'); |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
71 |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
72 ############################################################################### |