Mercurial > hg > nginx-tests
annotate gzip.t @ 104:8bc9de6559a1
Tests: add gzip module checks.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Tue, 13 Oct 2009 02:17:52 +0400 |
parents | b8b901f86518 |
children | 1c0ec30614c6 |
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 | |
28 master_process off; | |
29 daemon off; | |
30 | |
31 events { | |
32 } | |
33 | |
34 http { | |
35 access_log off; | |
36 root %%TESTDIR%%; | |
37 | |
38 client_body_temp_path %%TESTDIR%%/client_body_temp; | |
39 fastcgi_temp_path %%TESTDIR%%/fastcgi_temp; | |
40 proxy_temp_path %%TESTDIR%%/proxy_temp; | |
41 | |
42 server { | |
43 listen 127.0.0.1:8080; | |
44 server_name localhost; | |
45 location / { | |
46 gzip on; | |
47 } | |
48 location /proxy/ { | |
49 gzip on; | |
50 proxy_pass http://127.0.0.1:8080/local/; | |
51 } | |
52 location /local/ { | |
53 gzip off; | |
54 alias %%TESTDIR%%/; | |
55 } | |
56 } | |
57 } | |
58 | |
59 EOF | |
60 | |
61 $t->write_file('index.html', 'X' x 64); | |
62 | |
63 $t->run(); | |
64 | |
65 ############################################################################### | |
66 | |
67 my $r; | |
68 | |
69 $r = http_gzip_request('/'); | |
70 like($r, qr/^Content-Encoding: gzip/m, 'gzip'); | |
71 http_gzip_like($r, qr/^X{64}\Z/, 'gzip content correct'); | |
72 | |
73 $r = http_gzip_request('/proxy/'); | |
74 like($r, qr/^Content-Encoding: gzip/m, 'gzip proxied'); | |
75 http_gzip_like($r, qr/^X{64}\Z/, 'gzip proxied content'); | |
76 | |
77 # Accept-Ranges headers should be cleared | |
78 | |
79 unlike(http_gzip_request('/'), qr/Accept-Ranges/im, 'cleared accept-ranges'); | |
80 unlike(http_gzip_request('/proxy/'), qr/Accept-Ranges/im, | |
81 'cleared headers from proxy'); | |
82 | |
83 ############################################################################### |