Mercurial > hg > nginx-tests
annotate charset.t @ 1434:fc8341cf92a3
Tests: removed ngx_parse_inet6_url() "::" test from proxy.t.
It results in WSAEADDRNOTAVAIL on win32, be the connection errors detected,
which leads to connect() alert. On other systems, connect() is successful
but it uses the default port (80), which is out of documented ports range.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Thu, 24 Jan 2019 17:05:04 +0300 |
parents | 882267679006 |
children |
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; | |
19 | |
20 ############################################################################### | |
21 | |
22 select STDERR; $| = 1; | |
23 select STDOUT; $| = 1; | |
24 | |
25 my $t = Test::Nginx->new()->has(qw/http charset proxy/)->plan(7) | |
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 text/foo foo; | |
41 } | |
42 | |
43 charset_map B A { | |
44 58 59; # X -> Y | |
45 } | |
46 | |
47 server { | |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
48 listen 127.0.0.1:8080; |
399 | 49 server_name localhost; |
50 | |
51 location / { | |
52 charset utf-8; | |
53 } | |
54 | |
55 location /t3.foo { | |
56 charset utf-8; | |
57 charset_types text/foo; | |
58 } | |
59 | |
60 location /t4.any { | |
61 charset utf-8; | |
62 charset_types *; | |
63 } | |
64 | |
65 location /t5.html { | |
66 charset $arg_c; | |
67 } | |
68 | |
69 location /t.html { | |
70 charset A; | |
71 source_charset B; | |
72 } | |
73 | |
74 location /proxy/ { | |
75 charset B; | |
76 override_charset on; | |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
77 proxy_pass http://127.0.0.1:8080/; |
399 | 78 } |
79 } | |
80 } | |
81 | |
82 EOF | |
83 | |
84 $t->write_file('t1.html', ''); | |
85 $t->write_file('t2.foo', ''); | |
86 $t->write_file('t3.foo', ''); | |
87 $t->write_file('t4.any', ''); | |
88 $t->write_file('t5.html', ''); | |
89 $t->write_file('t.html', 'X' x 99); | |
90 | |
91 ############################################################################### | |
92 | |
93 like(http_get('/t1.html'), qr!text/html; charset=utf-8!, 'charset indicated'); | |
94 like(http_get('/t2.foo'), qr!text/foo\x0d!, 'wrong type'); | |
95 like(http_get('/t3.foo'), qr!text/foo; charset=utf-8!, 'charset_types'); | |
96 like(http_get('/t4.any'), qr!text/plain; charset=utf-8!, 'charset_types any'); | |
97 like(http_get('/t5.html?c=utf-8'), qr!text/html; charset=utf-8!, 'variables'); | |
98 | |
99 like(http_get('/t.html'), qr!Y{99}!, 'recode'); | |
100 like(http_get('/proxy/t.html'), qr!X{99}!, 'override charset'); | |
101 | |
102 ############################################################################### |