2010-06-04 05:12:19 -04:00
|
|
|
#!/usr/bin/env perl
|
2008-08-02 06:17:03 -04:00
|
|
|
|
|
|
|
use strict;
|
2008-11-26 10:14:27 -05:00
|
|
|
use warnings;
|
2008-08-02 06:17:03 -04:00
|
|
|
|
2009-09-05 16:54:05 -04:00
|
|
|
use WgetFeature qw(iri);
|
2008-08-02 06:17:03 -04:00
|
|
|
use HTTPTest;
|
|
|
|
|
|
|
|
# cf. http://en.wikipedia.org/wiki/Latin1
|
|
|
|
# http://en.wikipedia.org/wiki/ISO-8859-15
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
# Force remote encoding to ISO-8859-1
|
|
|
|
#
|
|
|
|
# mime : charset found in Content-Type HTTP MIME header
|
|
|
|
# meta : charset found in Content-Type meta tag
|
|
|
|
#
|
|
|
|
# index.html mime + file = iso-8859-15
|
|
|
|
# p1_français.html meta + file = iso-8859-1, mime = utf-8
|
|
|
|
# p2_één.html mime + file = iso-8859-1
|
|
|
|
# p3_€€€.html meta + file = utf-8, mime = iso-8859-1
|
|
|
|
#
|
|
|
|
|
|
|
|
my $ccedilla_l15 = "\xE7";
|
|
|
|
my $ccedilla_u8 = "\xC3\xA7";
|
|
|
|
my $eacute_l1 = "\xE9";
|
|
|
|
my $eacute_u8 = "\xC3\xA9";
|
|
|
|
my $eurosign_l15 = "\xA4";
|
|
|
|
my $eurosign_u8 = "\xE2\x82\xAC";
|
|
|
|
my $currency_l1 = "\xA4";
|
|
|
|
my $currency_u8 = "\xC2\xA4";
|
|
|
|
|
|
|
|
my $pageindex = <<EOF;
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<title>Main Page</title>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<p>
|
|
|
|
Link to page 1 <a href="http://localhost:{{port}}/p1_fran${ccedilla_l15}ais.html">La seule page en français</a>.
|
|
|
|
Link to page 3 <a href="http://localhost:{{port}}/p3_${eurosign_l15}${eurosign_l15}${eurosign_l15}.html">My tailor is rich</a>.
|
|
|
|
</p>
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
EOF
|
|
|
|
|
|
|
|
my $pagefrancais = <<EOF;
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<title>La seule page en français</title>
|
|
|
|
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<p>
|
|
|
|
Link to page 2 <a href="http://localhost:{{port}}/p2_${eacute_l1}${eacute_l1}n.html">Die enkele nerderlangstalige pagina</a>.
|
|
|
|
</p>
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
EOF
|
|
|
|
|
|
|
|
my $pageeen = <<EOF;
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<title>Die enkele nederlandstalige pagina</title>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<p>
|
|
|
|
Één is niet veel maar toch meer dan nul.<br/>
|
|
|
|
Nerdelands is een mooie taal... dit zin stuckje spreekt vanzelf, of niet :)
|
|
|
|
</p>
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
EOF
|
|
|
|
|
|
|
|
my $pageeuro = <<EOF;
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<title>Euro page</title>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<p>
|
|
|
|
My tailor isn't rich anymore.
|
|
|
|
</p>
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
EOF
|
|
|
|
|
|
|
|
my $page404 = <<EOF;
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<title>404</title>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<p>
|
|
|
|
Nop nop nop...
|
|
|
|
</p>
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
EOF
|
|
|
|
|
|
|
|
# code, msg, headers, content
|
|
|
|
my %urls = (
|
|
|
|
'/index.html' => {
|
|
|
|
code => "200",
|
|
|
|
msg => "Ok",
|
|
|
|
headers => {
|
|
|
|
"Content-type" => "text/html; charset=ISO-8859-15",
|
|
|
|
},
|
|
|
|
content => $pageindex,
|
|
|
|
},
|
|
|
|
'/robots.txt' => {
|
|
|
|
code => "200",
|
|
|
|
msg => "Ok",
|
|
|
|
headers => {
|
|
|
|
"Content-type" => "text/plain",
|
|
|
|
},
|
|
|
|
content => "",
|
|
|
|
},
|
|
|
|
'/p1_fran%C3%A7ais.html' => { # UTF-8 encoded
|
|
|
|
code => "404",
|
|
|
|
msg => "File not found",
|
|
|
|
headers => {
|
|
|
|
"Content-type" => "text/html; charset=UTF-8",
|
|
|
|
},
|
|
|
|
content => $page404,
|
|
|
|
},
|
|
|
|
'/p1_fran%E7ais.html' => {
|
|
|
|
code => "200",
|
|
|
|
msg => "Ok",
|
|
|
|
headers => {
|
|
|
|
"Content-type" => "text/html; charset=UTF-8",
|
|
|
|
},
|
|
|
|
content => $pagefrancais,
|
|
|
|
},
|
|
|
|
'/p2_%C3%A9%C3%A9n.html' => { # UTF-8 encoded
|
|
|
|
code => "200",
|
|
|
|
msg => "Ok",
|
|
|
|
headers => {
|
|
|
|
"Content-type" => "text/html; charset=UTF-8",
|
|
|
|
},
|
|
|
|
content => $pageeen,
|
|
|
|
},
|
|
|
|
'/p2_%E9%E9n.html' => {
|
|
|
|
code => "200",
|
|
|
|
msg => "Ok",
|
|
|
|
headers => {
|
|
|
|
"Content-type" => "text/html; charset=ISO-8859-1",
|
|
|
|
},
|
|
|
|
content => $pageeen,
|
|
|
|
},
|
|
|
|
'/p3_%E2%82%AC%E2%82%AC%E2%82%AC.html' => { # UTF-8 encoded
|
|
|
|
code => "200",
|
|
|
|
msg => "Ok",
|
|
|
|
headers => {
|
|
|
|
"Content-type" => "text/plain",
|
|
|
|
},
|
|
|
|
content => $pageeuro,
|
|
|
|
},
|
|
|
|
'/p3_%A4%A4%A4.html' => {
|
|
|
|
code => "200",
|
|
|
|
msg => "Ok",
|
|
|
|
headers => {
|
|
|
|
"Content-type" => "text/plain",
|
|
|
|
},
|
|
|
|
content => $pageeuro,
|
|
|
|
},
|
|
|
|
'/p3_%C2%A4%C2%A4%C2%A4.html' => { # UTF-8 encoded
|
|
|
|
code => "200",
|
|
|
|
msg => "Ok",
|
|
|
|
headers => {
|
|
|
|
"Content-type" => "text/plain",
|
|
|
|
},
|
|
|
|
content => $pageeuro,
|
|
|
|
},
|
|
|
|
);
|
|
|
|
|
2010-09-12 09:21:50 -04:00
|
|
|
my $cmdline = $WgetTest::WGETPATH . " --iri --trust-server-names --remote-encoding=iso-8859-1 -nH -r http://localhost:{{port}}/";
|
2008-08-02 06:17:03 -04:00
|
|
|
|
|
|
|
my $expected_error_code = 0;
|
|
|
|
|
|
|
|
my %expected_downloaded_files = (
|
|
|
|
'index.html' => {
|
|
|
|
content => $pageindex,
|
|
|
|
},
|
|
|
|
'robots.txt' => {
|
|
|
|
content => "",
|
|
|
|
},
|
|
|
|
"p1_fran${ccedilla_l15}ais.html" => {
|
|
|
|
content => $pagefrancais,
|
|
|
|
},
|
|
|
|
"p2_${eacute_u8}${eacute_u8}n.html" => {
|
|
|
|
content => $pageeen,
|
|
|
|
},
|
|
|
|
"p3_${currency_u8}${currency_u8}${currency_u8}.html" => {
|
|
|
|
content => $pageeuro,
|
|
|
|
},
|
|
|
|
);
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
|
|
|
|
my $the_test = HTTPTest->new (name => "Test-iri-forced-remote",
|
2009-09-21 23:39:44 -04:00
|
|
|
input => \%urls,
|
|
|
|
cmdline => $cmdline,
|
|
|
|
errcode => $expected_error_code,
|
2008-08-02 06:17:03 -04:00
|
|
|
output => \%expected_downloaded_files);
|
|
|
|
exit $the_test->run();
|
|
|
|
|
|
|
|
# vim: et ts=4 sw=4
|