diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-10 20:25:44 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-10 20:25:44 +0000 |
commit | b3925d944ed94cc76bbcbb14a799ec9beeb8d1bf (patch) | |
tree | a5e5ccdbc84294390695b5ae3a8c89cc16e6cbae /tests/Test-iri-list.px | |
parent | Initial commit. (diff) | |
download | wget-b3925d944ed94cc76bbcbb14a799ec9beeb8d1bf.tar.xz wget-b3925d944ed94cc76bbcbb14a799ec9beeb8d1bf.zip |
Adding upstream version 1.21.4.upstream/1.21.4
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/Test-iri-list.px')
-rwxr-xr-x | tests/Test-iri-list.px | 173 |
1 files changed, 173 insertions, 0 deletions
diff --git a/tests/Test-iri-list.px b/tests/Test-iri-list.px new file mode 100755 index 0000000..5e56072 --- /dev/null +++ b/tests/Test-iri-list.px @@ -0,0 +1,173 @@ +#!/usr/bin/env perl + +use strict; +use warnings; + +use WgetFeature qw(iri); +use HTTPTest; + +# cf. http://en.wikipedia.org/wiki/Latin1 +# http://en.wikipedia.org/wiki/ISO-8859-15 +############################################################################### +# +# 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 meta + file = utf-8, mime =iso-8859-1 +# + +my $ccedilla_l1 = "\xE7"; +my $ccedilla_u8 = "\xC3\xA7"; +my $eacute_l1 = "\xE9"; +my $eacute_u8 = "\xC3\xA9"; + +my $urllist = <<EOF; +http://localhost:{{port}}/ +http://localhost:{{port}}/p1_fran${ccedilla_l1}ais.html +http://localhost:{{port}}/p2_${eacute_l1}${eacute_l1}n.html +EOF + +my $pageindex = <<EOF; +<html> +<head> + <title>Main Page</title> +</head> +<body> + <p> + Main page. + </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> + French page. + </p> +</body> +</html> +EOF + +my $pageeen = <<EOF; +<html> +<head> + <title>Die enkele nederlandstalige pagina</title> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> +</head> +<body> + <p> + Dutch page. + </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=ISO-8859-1", + }, + content => $pageeen, + }, + '/p2_%E9%E9n.html' => { + code => "200", + msg => "Ok", + headers => { + "Content-type" => "text/html; charset=ISO-8859-1", + }, + content => $pageeen, + }, + '/url_list.txt' => { + code => "200", + msg => "Ok", + headers => { + "Content-type" => "text/plain; charset=ISO-8859-1", + }, + content => $urllist, + }, +); + +my $cmdline = $WgetTest::WGETPATH . " --iri --trust-server-names -i http://localhost:{{port}}/url_list.txt"; + +my $expected_error_code = 0; + +my %expected_downloaded_files = ( + 'url_list.txt' => { + content => $urllist, + }, + 'index.html' => { + content => $pageindex, + }, + "p1_fran${ccedilla_l1}ais.html" => { + content => $pagefrancais, + }, + "p2_${eacute_u8}${eacute_u8}n.html" => { + content => $pageeen, + }, +); + +############################################################################### + +my $the_test = HTTPTest->new (input => \%urls, + cmdline => $cmdline, + errcode => $expected_error_code, + output => \%expected_downloaded_files); +exit $the_test->run(); + +# vim: et ts=4 sw=4 |