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