]> sjero.net Git - wget/blob - tests/Test-iri-list.px
Updated config.guess, config.sub, install.sh.
[wget] / tests / Test-iri-list.px
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 use HTTPTest;
7
8 # cf. http://en.wikipedia.org/wiki/Latin1
9 #     http://en.wikipedia.org/wiki/ISO-8859-15
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                 meta + file = utf-8, mime =iso-8859-1
18 #
19
20 my $ccedilla_l1 = "\xE7";
21 my $ccedilla_u8 = "\xC3\xA7";
22 my $eacute_l1 = "\xE9";
23 my $eacute_u8 = "\xC3\xA9";
24
25 my $urllist = <<EOF;
26 http://localhost:{{port}}/
27 http://localhost:{{port}}/p1_fran${ccedilla_l1}ais.html
28 http://localhost:{{port}}/p2_${eacute_l1}${eacute_l1}n.html
29 EOF
30
31 my $pageindex = <<EOF;
32 <html>
33 <head>
34   <title>Main Page</title>
35 </head>
36 <body>
37   <p>
38         Main page.
39   </p>
40 </body>
41 </html>
42 EOF
43
44 my $pagefrancais = <<EOF;
45 <html>
46 <head>
47   <title>La seule page en français</title>
48   <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
49 </head>
50 <body>
51   <p>
52     French page.
53   </p>
54 </body>
55 </html>
56 EOF
57
58 my $pageeen = <<EOF;
59 <html>
60 <head>
61   <title>Die enkele nederlandstalige pagina</title>
62   <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
63 </head>
64 <body>
65   <p>
66     Dutch page.
67   </p>
68 </body>
69 </html>
70 EOF
71
72 my $page404 = <<EOF;
73 <html>
74 <head>
75   <title>404</title>
76 </head>
77 <body>
78   <p>
79     Nop nop nop...
80   </p>
81 </body>
82 </html>
83 EOF
84
85 # code, msg, headers, content
86 my %urls = (
87     '/index.html' => {
88         code => "200",
89         msg => "Ok",
90         headers => {
91             "Content-type" => "text/html; charset=ISO-8859-15",
92         },
93         content => $pageindex,
94     },
95     '/robots.txt' => {
96         code => "200",
97         msg => "Ok",
98         headers => {
99             "Content-type" => "text/plain",
100         },
101         content => "",
102     },
103     '/p1_fran%C3%A7ais.html' => {       # UTF-8 encoded
104         code => "404",
105         msg => "File not found",
106         headers => {
107             "Content-type" => "text/html; charset=UTF-8",
108         },
109         content => $page404,
110     },
111     '/p1_fran%E7ais.html' => {
112         code => "200",
113         msg => "Ok",
114         headers => {
115             "Content-type" => "text/html; charset=UTF-8",
116         },
117         content => $pagefrancais,
118     },
119     '/p2_%C3%A9%C3%A9n.html' => {       # UTF-8 encoded
120         code => "200",
121         msg => "Ok",
122         headers => {
123             "Content-type" => "text/html; charset=ISO-8859-1",
124         },
125         content => $pageeen,
126     },
127     '/p2_%E9%E9n.html' => {
128         code => "200",
129         msg => "Ok",
130         headers => {
131             "Content-type" => "text/html; charset=ISO-8859-1",
132         },
133         content => $pageeen,
134     },
135     '/url_list.txt' => {
136         code => "200",
137         msg => "Ok",
138         headers => {
139             "Content-type" => "text/plain; charset=ISO-8859-1",
140         },
141         content => $urllist,
142     },
143 );
144
145 my $cmdline = $WgetTest::WGETPATH . " --iri -d -i http://localhost:{{port}}/url_list.txt";
146
147 my $expected_error_code = 0;
148
149 my %expected_downloaded_files = (
150     'url_list.txt' => {
151         content => $urllist,
152     },
153     'index.html' => {
154         content => $pageindex,
155     },
156     "p1_fran${ccedilla_l1}ais.html" => {
157         content => $pagefrancais,
158     },
159     "p2_${eacute_u8}${eacute_u8}n.html" => {
160         content => $pageeen,
161     },
162 );
163
164 ###############################################################################
165
166 my $the_test = HTTPTest->new (name => "Test-iri-list",
167                               input => \%urls, 
168                               cmdline => $cmdline, 
169                               errcode => $expected_error_code, 
170                               output => \%expected_downloaded_files);
171 exit $the_test->run();
172
173 # vim: et ts=4 sw=4
174