Mercurial > hg > nginx-tests
annotate charset_gzip_static.t @ 572:ca54b445d982
Tests: masked nginx bug in proxy next upstream.
When iterating through several next upstreams per a worker cycle,
a previously reported event about upstream connection error may
be improperly applied to the next upstream, thus leading to the
invalid connection error. E.g., in kqueue, where the problem is
visible, this is caused by "ev->instance" that does not tolerate
more than one next upstream at once, and kevents placed on the
kqueue separately for read and write events.
The change is to limit test case to the only one next upstream.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Thu, 14 May 2015 11:54:24 +0300 |
parents | 907e89fba9c3 |
children | 3ac4036b139d |
rev | line source |
---|---|
399 | 1 #!/usr/bin/perl |
2 | |
3 # (C) Maxim Dounin | |
4 # (C) Nginx, Inc. | |
5 | |
6 # Tests for charset filter. | |
7 | |
8 ############################################################################### | |
9 | |
10 use warnings; | |
11 use strict; | |
12 | |
13 use Test::More; | |
14 | |
15 BEGIN { use FindBin; chdir($FindBin::Bin); } | |
16 | |
17 use lib 'lib'; | |
18 use Test::Nginx qw/ :DEFAULT :gzip /; | |
19 | |
20 ############################################################################### | |
21 | |
22 select STDERR; $| = 1; | |
23 select STDOUT; $| = 1; | |
24 | |
25 my $t = Test::Nginx->new()->has(qw/http charset gzip_static/)->plan(13) | |
26 ->write_file_expand('nginx.conf', <<'EOF')->run(); | |
27 | |
28 %%TEST_GLOBALS%% | |
29 | |
30 daemon off; | |
31 | |
32 events { | |
33 } | |
34 | |
35 http { | |
36 %%TEST_GLOBALS_HTTP%% | |
37 | |
38 types { | |
39 text/html html; | |
40 } | |
41 | |
42 charset_map B A { | |
43 58 59; # X -> Y | |
44 } | |
45 | |
46 server { | |
47 listen 127.0.0.1:8080; | |
48 server_name localhost; | |
49 | |
50 location /t1 { | |
51 charset utf-8; | |
52 gzip_static on; | |
53 } | |
54 | |
55 location /t2 { | |
56 gzip_static on; | |
57 charset A; | |
58 source_charset B; | |
59 } | |
60 | |
61 location /t { | |
62 gzip_static on; | |
63 } | |
64 | |
65 location /p/ { | |
66 charset utf-8; | |
67 proxy_pass http://127.0.0.1:8080/; | |
68 proxy_http_version 1.1; | |
69 } | |
70 | |
71 location /p.ab/ { | |
72 charset A; | |
73 source_charset B; | |
74 proxy_pass http://127.0.0.1:8080/; | |
75 proxy_http_version 1.1; | |
76 } | |
77 | |
78 location /p.aa/ { | |
79 charset A; | |
80 source_charset A; | |
81 proxy_pass http://127.0.0.1:8080/; | |
82 proxy_http_version 1.1; | |
83 } | |
84 } | |
85 } | |
86 | |
87 EOF | |
88 | |
89 $t->write_file('t1.html', ''); | |
90 $t->write_file('t1.html.gz', ''); | |
91 | |
92 my $in = 'X' x 99; | |
93 my $out; | |
94 | |
95 eval { | |
405
a8bfad2a3f84
Tests: whitespace fix.
Sergey Kandaurov <pluknet@nginx.com>
parents:
403
diff
changeset
|
96 require IO::Compress::Gzip; |
399 | 97 IO::Compress::Gzip::gzip(\$in => \$out); |
98 }; | |
99 | |
100 $t->write_file('t2.html', $in); | |
101 $t->write_file('t2.html.gz', $out); | |
102 | |
103 $t->write_file('t.html', ''); | |
104 $t->write_file('t.html.gz', ''); | |
105 | |
106 ############################################################################### | |
107 | |
108 # charset filter currently ignores responses with Content-Encoding set | |
109 # (except ones with r->ignore_content_encoding used by gzip_static) | |
110 # as it can't convert such content; there are two problems though: | |
111 # | |
112 # - it make sense to indicate charset | |
113 # if conversion isn't needed | |
114 # | |
115 # - gzip_static may need conversion, too | |
116 # | |
117 # proper solution seems to be to always allow charset indication, but | |
118 # don't try to do anything if recoding is needed | |
119 | |
120 like(http_get('/t1.html'), qr!text/html; charset=!, 'plain'); | |
121 like(http_gzip_request('/t1.html'), qr!text/html; charset=.*gzip!ms, 'gzip'); | |
122 | |
123 like(http_get('/t2.html'), qr!text/html; charset=A.*Y{99}!ms, 'recode plain'); | |
124 like(http_gzip_request('/t2.html'), qr!text/html\x0d.*gzip!ms, 'recode gzip'); | |
125 http_gzip_like(http_gzip_request('/t2.html'), qr!X{99}!, 'recode content'); | |
126 | |
127 like(http_get('/t.html'), qr!text/html\x0d!, 'nocharset plain'); | |
128 like(http_gzip_request('/t.html'), qr!text/html\x0d.*gzip!ms, 'nocharset gzip'); | |
129 | |
130 like(http_get('/p/t.html'), qr!text/html; charset=!, 'proxy plain'); | |
131 like(http_gzip_request('/p/t.html'), qr!text/html; charset=.*gzip!ms, | |
132 'proxy gzip'); | |
133 | |
134 like(http_get('/p.ab/t.html'), qr!text/html; charset=A!ms, | |
135 'proxy recode plain'); | |
401
2961a6a83809
Tests: fixed charset_gzip_static.t tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
399
diff
changeset
|
136 like(http_gzip_request('/p.ab/t.html'), qr!text/html\x0d.*gzip!ms, |
399 | 137 'proxy recode gzip'); |
138 | |
401
2961a6a83809
Tests: fixed charset_gzip_static.t tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
399
diff
changeset
|
139 like(http_get('/p.aa/t.html'), qr!text/html; charset=A!ms, |
399 | 140 'proxy nullrecode plain'); |
401
2961a6a83809
Tests: fixed charset_gzip_static.t tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
399
diff
changeset
|
141 like(http_gzip_request('/p.aa/t.html'), qr!text/html; charset=A.*gzip!ms, |
399 | 142 'proxy nullrecode gzip'); |
143 | |
144 ############################################################################### |