Mercurial > hg > nginx-tests
annotate gzip.t @ 114:44b281ac4bc6
Tests: add server name tests, including fancy regex ones.
With test config nginx will fail to start as of 0.8.28 due to incorrect
conversion of regular expressions to lowercase. Patch was discussed on
mailing list and will be included in next release.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Mon, 30 Nov 2009 14:47:17 +0300 |
parents | 1c0ec30614c6 |
children | c8341d95297e |
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 | |
104
8bc9de6559a1
Tests: add gzip module checks.
Maxim Dounin <mdounin@mdounin.ru>
parents:
98
diff
changeset
|
24 my $t = Test::Nginx->new()->has('gzip')->plan(6); |
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 |
93 | 30 master_process off; |
31 daemon off; | |
32 | |
33 events { | |
34 } | |
35 | |
36 http { | |
107
1c0ec30614c6
Tests: add TEST_GLOBALS and TEST_GLOBALS_HTTP config chunks.
Maxim Dounin <mdounin@mdounin.ru>
parents:
104
diff
changeset
|
37 %%TEST_GLOBALS_HTTP%% |
93 | 38 |
39 server { | |
40 listen 127.0.0.1:8080; | |
41 server_name localhost; | |
42 location / { | |
43 gzip on; | |
44 } | |
45 location /proxy/ { | |
46 gzip on; | |
47 proxy_pass http://127.0.0.1:8080/local/; | |
48 } | |
49 location /local/ { | |
50 gzip off; | |
51 alias %%TESTDIR%%/; | |
52 } | |
53 } | |
54 } | |
55 | |
56 EOF | |
57 | |
58 $t->write_file('index.html', 'X' x 64); | |
59 | |
60 $t->run(); | |
61 | |
62 ############################################################################### | |
63 | |
64 my $r; | |
65 | |
66 $r = http_gzip_request('/'); | |
67 like($r, qr/^Content-Encoding: gzip/m, 'gzip'); | |
68 http_gzip_like($r, qr/^X{64}\Z/, 'gzip content correct'); | |
69 | |
70 $r = http_gzip_request('/proxy/'); | |
71 like($r, qr/^Content-Encoding: gzip/m, 'gzip proxied'); | |
72 http_gzip_like($r, qr/^X{64}\Z/, 'gzip proxied content'); | |
73 | |
74 # Accept-Ranges headers should be cleared | |
75 | |
76 unlike(http_gzip_request('/'), qr/Accept-Ranges/im, 'cleared accept-ranges'); | |
77 unlike(http_gzip_request('/proxy/'), qr/Accept-Ranges/im, | |
78 'cleared headers from proxy'); | |
79 | |
80 ############################################################################### |