Mercurial > hg > nginx-tests
comparison gzip.t @ 93:5276d85d5040
Tests: add basic gzip tests.
This also includes clearing Accept-Ranges header got from upstream (broken
since 0.7.44).
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Tue, 26 May 2009 20:18:05 +0400 |
parents | |
children | b8b901f86518 |
comparison
equal
deleted
inserted
replaced
92:390588796411 | 93:5276d85d5040 |
---|---|
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 | |
24 my $t = Test::Nginx->new()->plan(6); | |
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 | |
81 TODO: { | |
82 local $TODO = 'broken since 0.7.44'; | |
83 | |
84 unlike(http_gzip_request('/proxy/'), qr/Accept-Ranges/im, | |
85 'cleared headers from proxy'); | |
86 | |
87 } | |
88 | |
89 ############################################################################### |