]> sjero.net Git - wget/blob - tests/Test-iri-disabled.px
17e43361a2f5d3649de24c024c55909220950a09
[wget] / tests / Test-iri-disabled.px
1 #!/usr/bin/perl -w
2
3 use strict;
4
5 use HTTPTest;
6
7 # cf. http://en.wikipedia.org/wiki/Latin1
8 #     http://en.wikipedia.org/wiki/ISO-8859-15
9
10 ###############################################################################
11 #
12 # mime : charset found in Content-Type HTTP MIME header
13 # meta : charset found in Content-Type meta tag
14 #
15 # index.html                  mime + file = iso-8859-15
16 # p1_français.html            meta + file = iso-8859-1, mime = utf-8
17 # p2_één.html                 mime + file = iso-8859-1
18 # p3_€€€.html                 meta + file = utf-8, mime = iso-8859-1
19 #
20
21 my $ccedilla_l15 = "\xE7";
22 my $ccedilla_u8 = "\xC3\xA7";
23 my $eacute_l1 = "\xE9";
24 my $eacute_u8 = "\xC3\xA9";
25 my $eurosign_l15 = "\xA4";
26 my $eurosign_u8 = "\xE2\x82\xAC";
27
28 my $pageindex = <<EOF;
29 <html>
30 <head>
31   <title>Main Page</title>
32 </head>
33 <body>
34   <p>
35     Link to page 1 <a href="http://localhost:{{port}}/p1_fran${ccedilla_l15}ais.html">La seule page en fran&ccedil;ais</a>.
36     Link to page 3 <a href="http://localhost:{{port}}/p3_${eurosign_l15}${eurosign_l15}${eurosign_l15}.html">My tailor is rich</a>.
37   </p>
38 </body>
39 </html>
40 EOF
41
42 my $pagefrancais = <<EOF;
43 <html>
44 <head>
45   <title>La seule page en français</title>
46   <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
47 </head>
48 <body>
49   <p>
50     Link to page 2 <a href="http://localhost:{{port}}/p2_${eacute_l1}${eacute_l1}n.html">Die enkele nerderlangstalige pagina</a>.
51   </p>
52 </body>
53 </html>
54 EOF
55
56 my $pageeen = <<EOF;
57 <html>
58 <head>
59   <title>Die enkele nederlandstalige pagina</title>
60 </head>
61 <body>
62   <p>
63     &Eacute;&eacute;n is niet veel maar toch meer dan nul.<br/>
64     Nerdelands is een mooie taal... dit zin stuckje spreekt vanzelf, of niet :)
65   </p>
66 </body>
67 </html>
68 EOF
69
70 my $pageeuro = <<EOF;
71 <html>
72 <head>
73   <title>Euro page</title>
74 </head>
75 <body>
76   <p>
77     My tailor isn't rich anymore.
78   </p>
79 </body>
80 </html>
81 EOF
82
83 my $page404 = <<EOF;
84 <html>
85 <head>
86   <title>404</title>
87 </head>
88 <body>
89   <p>
90     Nop nop nop...
91   </p>
92 </body>
93 </html>
94 EOF
95
96 # code, msg, headers, content
97 my %urls = (
98     '/index.html' => {
99         code => "200",
100         msg => "Ok",
101         headers => {
102             "Content-type" => "text/html; charset=ISO-8859-15",
103         },
104         content => $pageindex,
105     },
106     '/robots.txt' => {
107         code => "200",
108         msg => "Ok",
109         headers => {
110             "Content-type" => "text/plain",
111         },
112         content => "",
113     },
114     '/p1_fran%C3%A7ais.html' => {       # UTF-8 encoded
115         code => "200",
116         msg => "File not found",
117         headers => {
118             "Content-type" => "text/html; charset=UTF-8",
119         },
120         content => $pagefrancais,
121     },
122     '/p1_fran%E7ais.html' => {
123         code => "200",
124         msg => "Ok",
125         headers => {
126             "Content-type" => "text/html; charset=UTF-8",
127         },
128         content => $pagefrancais,
129     },
130     '/p2_%C3%A9%C3%A9n.html' => {       # UTF-8 encoded
131         code => "200",
132         msg => "Ok",
133         headers => {
134             "Content-type" => "text/html; charset=UTF-8",
135         },
136         content => $pageeen,
137     },
138     '/p2_%E9%E9n.html' => {
139         code => "200",
140         msg => "Ok",
141         headers => {
142             "Content-type" => "text/html; charset=ISO-8859-1",
143         },
144         content => $pageeen,
145     },
146     '/p3_%E2%82%AC%E2%82%AC%E2%82%AC.html' => { # UTF-8 encoded
147         code => "200",
148         msg => "Ok",
149         headers => {
150             "Content-type" => "text/plain",
151         },
152         content => $pageeuro,
153     },
154     '/p3_%A4%A4%A4.html' => {
155         code => "200",
156         msg => "Ok",
157         headers => {
158             "Content-type" => "text/plain",
159         },
160         content => $pageeuro,
161     },
162 );
163
164 my $cmdline = $WgetTest::WGETPATH . " --iri=no -nH -r http://localhost:{{port}}/";
165
166 my $expected_error_code = 0;
167
168 my %expected_downloaded_files = (
169     'index.html' => {
170         content => $pageindex,
171     },
172     'robots.txt' => {
173         content => "",
174     },
175     "p1_fran${ccedilla_l15}ais.html" => {
176         content => $pagefrancais,
177     },
178     "p2_${eacute_l1}${eacute_l1}n.html" => {
179         content => $pageeen,
180     },
181     "p3_${eurosign_l15}${eurosign_l15}${eurosign_l15}.html" => {
182         content => $pageeuro,
183     },
184 );
185
186 ###############################################################################
187
188 my $the_test = HTTPTest->new (name => "Test-iri-disabled",
189                               input => \%urls, 
190                               cmdline => $cmdline, 
191                               errcode => $expected_error_code, 
192                               output => \%expected_downloaded_files);
193 exit $the_test->run();
194
195 # vim: et ts=4 sw=4
196