Mercurial > hg > nginx-tests
annotate gzip.t @ 1215:26884729e06b
Tests: cope with resolver resend in mail resolver tests.
Currently, if resolver didn't find PTR type in the answer section of PTR
response, it keeps the node in the resend queue until the next timer event.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Thu, 31 Aug 2017 19:09:04 +0300 |
parents | 882267679006 |
children |
rev | line source |
---|---|
93 | 1 #!/usr/bin/perl |
2 | |
3 # (C) Maxim Dounin | |
4 | |
5 # Tests for nginx gzip filter 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 | |
121
8ac1faaddd2c
Tests: better handle various configure arguments.
Maxim Dounin <mdounin@mdounin.ru>
parents:
116
diff
changeset
|
24 my $t = Test::Nginx->new()->has(qw/http proxy gzip/)->plan(8); |
93 | 25 |
26 $t->write_file_expand('nginx.conf', <<'EOF'); | |
27 | |
107
1c0ec30614c6
Tests: add TEST_GLOBALS and TEST_GLOBALS_HTTP config chunks.
Maxim Dounin <mdounin@mdounin.ru>
parents:
104
diff
changeset
|
28 %%TEST_GLOBALS%% |
1c0ec30614c6
Tests: add TEST_GLOBALS and TEST_GLOBALS_HTTP config chunks.
Maxim Dounin <mdounin@mdounin.ru>
parents:
104
diff
changeset
|
29 |
249
6a0d934950bc
Tests: remove extra spaces in "daemon off".
Maxim Dounin <mdounin@mdounin.ru>
parents:
166
diff
changeset
|
30 daemon off; |
93 | 31 |
32 events { | |
33 } | |
34 | |
35 http { | |
107
1c0ec30614c6
Tests: add TEST_GLOBALS and TEST_GLOBALS_HTTP config chunks.
Maxim Dounin <mdounin@mdounin.ru>
parents:
104
diff
changeset
|
36 %%TEST_GLOBALS_HTTP%% |
93 | 37 |
38 server { | |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
39 listen 127.0.0.1:8080; |
93 | 40 server_name localhost; |
41 location / { | |
42 gzip on; | |
43 } | |
44 location /proxy/ { | |
45 gzip on; | |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
46 proxy_pass http://127.0.0.1:8080/local/; |
93 | 47 } |
48 location /local/ { | |
49 gzip off; | |
50 alias %%TESTDIR%%/; | |
51 } | |
52 } | |
53 } | |
54 | |
55 EOF | |
56 | |
57 $t->write_file('index.html', 'X' x 64); | |
58 | |
59 $t->run(); | |
60 | |
61 ############################################################################### | |
62 | |
63 my $r; | |
64 | |
65 $r = http_gzip_request('/'); | |
66 like($r, qr/^Content-Encoding: gzip/m, 'gzip'); | |
67 http_gzip_like($r, qr/^X{64}\Z/, 'gzip content correct'); | |
68 | |
69 $r = http_gzip_request('/proxy/'); | |
70 like($r, qr/^Content-Encoding: gzip/m, 'gzip proxied'); | |
71 http_gzip_like($r, qr/^X{64}\Z/, 'gzip proxied content'); | |
72 | |
73 # Accept-Ranges headers should be cleared | |
74 | |
75 unlike(http_gzip_request('/'), qr/Accept-Ranges/im, 'cleared accept-ranges'); | |
76 unlike(http_gzip_request('/proxy/'), qr/Accept-Ranges/im, | |
77 'cleared headers from proxy'); | |
78 | |
116
c8341d95297e
Tests: add some HEAD gzip tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
107
diff
changeset
|
79 # HEAD requests should return correct headers |
c8341d95297e
Tests: add some HEAD gzip tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
107
diff
changeset
|
80 |
c8341d95297e
Tests: add some HEAD gzip tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
107
diff
changeset
|
81 like(http_gzip_head('/'), qr/Content-Encoding: gzip/, 'gzip head'); |
c8341d95297e
Tests: add some HEAD gzip tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
107
diff
changeset
|
82 unlike(http_head('/'), qr/Content-Encoding: gzip/, 'no gzip head'); |
c8341d95297e
Tests: add some HEAD gzip tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
107
diff
changeset
|
83 |
93 | 84 ############################################################################### |
116
c8341d95297e
Tests: add some HEAD gzip tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
107
diff
changeset
|
85 |
c8341d95297e
Tests: add some HEAD gzip tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
107
diff
changeset
|
86 sub http_gzip_head { |
c8341d95297e
Tests: add some HEAD gzip tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
107
diff
changeset
|
87 my ($uri) = @_; |
c8341d95297e
Tests: add some HEAD gzip tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
107
diff
changeset
|
88 return http(<<EOF); |
c8341d95297e
Tests: add some HEAD gzip tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
107
diff
changeset
|
89 HEAD $uri HTTP/1.1 |
c8341d95297e
Tests: add some HEAD gzip tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
107
diff
changeset
|
90 Host: localhost |
c8341d95297e
Tests: add some HEAD gzip tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
107
diff
changeset
|
91 Connection: close |
c8341d95297e
Tests: add some HEAD gzip tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
107
diff
changeset
|
92 Accept-Encoding: gzip |
c8341d95297e
Tests: add some HEAD gzip tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
107
diff
changeset
|
93 |
c8341d95297e
Tests: add some HEAD gzip tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
107
diff
changeset
|
94 EOF |
c8341d95297e
Tests: add some HEAD gzip tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
107
diff
changeset
|
95 } |
c8341d95297e
Tests: add some HEAD gzip tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
107
diff
changeset
|
96 |
c8341d95297e
Tests: add some HEAD gzip tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
107
diff
changeset
|
97 ############################################################################### |