]> sjero.net Git - wget/blob - tests/Test-iri-percent.px
Updated config.guess, config.sub, install.sh.
[wget] / tests / Test-iri-percent.px
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 use HTTPTest;
7
8 # Just a sanity check to verify that %-encoded values are always left
9 # untouched.
10
11 my $ccedilla_l15 = "\xE7";
12 my $ccedilla_l15_pct = "%E7";
13 my $eacute_l1 = "\xE9";
14 my $eacute_u8 = "\xC3\xA9";
15 my $eacute_u8_pct = "%C3%A9";
16
17 my $pageindex = <<EOF;
18 <html>
19 <head>
20   <title>Main Page</title>
21 </head>
22 <body>
23   <p>
24     Link to page 1 <a
25     href="http://localhost:{{port}}/hello_${ccedilla_l15_pct}${eacute_l1}.html">La seule page en fran&ccedil;ais</a>.
26   </p>
27 </body>
28 </html>
29 EOF
30
31 my $pagefrancais = <<EOF;
32 <html>
33 <head>
34   <title>La seule page en français</title>
35   <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
36 </head>
37 <body>
38   <p>
39   </p>
40 </body>
41 </html>
42 EOF
43
44 # code, msg, headers, content
45 my %urls = (
46     '/index.html' => {
47         code => "200",
48         msg => "Ok",
49         headers => {
50             "Content-type" => "text/html; charset=ISO-8859-15",
51         },
52         content => $pageindex,
53     },
54     "/hello_${ccedilla_l15_pct}${eacute_u8_pct}.html" => {
55         code => "200",
56         msg => "Ok",
57         headers => {
58             "Content-type" => "text/html; charset=UTF-8",
59         },
60         content => $pagefrancais,
61     },
62 );
63
64 my $cmdline = $WgetTest::WGETPATH . " --iri -e robots=off --restrict-file-names=nocontrol -nH -r http://localhost:{{port}}/";
65
66 my $expected_error_code = 0;
67
68 my %expected_downloaded_files = (
69     'index.html' => {
70         content => $pageindex,
71     },
72     "hello_${ccedilla_l15}${eacute_u8}.html" => {
73         content => $pagefrancais,
74     },
75 );
76
77 ###############################################################################
78
79 my $the_test = HTTPTest->new (name => "Test-iri-percent",
80                               input => \%urls,
81                               cmdline => $cmdline,
82                               errcode => $expected_error_code,
83                               output => \%expected_downloaded_files);
84 exit $the_test->run();
85
86 # vim: et ts=4 sw=4
87