| 1 |
#!/usr/bin/env perl |
| 2 |
|
| 3 |
use strict; |
| 4 |
use warnings; |
| 5 |
|
| 6 |
use WgetFeature qw(iri); |
| 7 |
use HTTPTest; |
| 8 |
|
| 9 |
# " Kon'nichiwa <dot> Japan |
| 10 |
my $euc_jp_hostname = "\272\243\306\374\244\317.\306\374\313\334"; |
| 11 |
my $punycoded_hostname = 'xn--v9ju72g90p.xn--wgv71a'; |
| 12 |
my $escaped_hostname = "%ba%a3%c6%fc%a4%cf.%c6%fc%cb%dc"; |
| 13 |
|
| 14 |
############################################################################### |
| 15 |
|
| 16 |
my $starter_file = <<EOF; |
| 17 |
<a href="http://$euc_jp_hostname/foo.txt">The link</a> |
| 18 |
<a href="http://$punycoded_hostname/foo2.txt">The second link</a> |
| 19 |
<a href="http://$escaped_hostname/foo3.txt">The third link</a> |
| 20 |
EOF |
| 21 |
|
| 22 |
my $result_file = <<EOF; |
| 23 |
Found me! |
| 24 |
EOF |
| 25 |
|
| 26 |
# code, msg, headers, content |
| 27 |
my %urls = ( |
| 28 |
"http://$punycoded_hostname/index.html" => { |
| 29 |
code => "200", |
| 30 |
msg => "Yes, please", |
| 31 |
headers => { |
| 32 |
'Content-Type' => 'text/html; charset=EUC-JP', |
| 33 |
}, |
| 34 |
content => $starter_file, |
| 35 |
}, |
| 36 |
"http://$punycoded_hostname/foo.txt" => { |
| 37 |
code => "200", |
| 38 |
msg => "Uh-huh", |
| 39 |
headers => { |
| 40 |
'Content-Type' => 'text/plain', |
| 41 |
}, |
| 42 |
content => $result_file, |
| 43 |
}, |
| 44 |
"http://$punycoded_hostname/foo2.txt" => { |
| 45 |
code => "200", |
| 46 |
msg => "Uh-huh2", |
| 47 |
headers => { |
| 48 |
'Content-Type' => 'text/plain', |
| 49 |
}, |
| 50 |
content => $result_file, |
| 51 |
}, |
| 52 |
"http://$punycoded_hostname/foo3.txt" => { |
| 53 |
code => "200", |
| 54 |
msg => "Uh-huh3", |
| 55 |
headers => { |
| 56 |
'Content-Type' => 'text/plain', |
| 57 |
}, |
| 58 |
content => $result_file, |
| 59 |
}, |
| 60 |
"http://$punycoded_hostname/robots.txt" => { |
| 61 |
code => "200", |
| 62 |
msg => "Uh-huh", |
| 63 |
headers => { |
| 64 |
'Content-Type' => 'text/plain', |
| 65 |
}, |
| 66 |
content => '', |
| 67 |
}, |
| 68 |
); |
| 69 |
|
| 70 |
my $cmdline = $WgetTest::WGETPATH . " --iri -r" |
| 71 |
. " -e http_proxy=localhost:{{port}} --local-encoding=EUC-JP" |
| 72 |
. " http://$euc_jp_hostname/"; |
| 73 |
|
| 74 |
my $expected_error_code = 0; |
| 75 |
|
| 76 |
my %expected_downloaded_files = ( |
| 77 |
"$punycoded_hostname/index.html" => { |
| 78 |
content => $starter_file, |
| 79 |
}, |
| 80 |
"$punycoded_hostname/foo.txt" => { |
| 81 |
content => $result_file, |
| 82 |
}, |
| 83 |
"$punycoded_hostname/foo2.txt" => { |
| 84 |
content => $result_file, |
| 85 |
}, |
| 86 |
"$punycoded_hostname/foo3.txt" => { |
| 87 |
content => $result_file, |
| 88 |
}, |
| 89 |
"$punycoded_hostname/robots.txt" => { |
| 90 |
content => '', |
| 91 |
}, |
| 92 |
); |
| 93 |
|
| 94 |
############################################################################### |
| 95 |
|
| 96 |
my $the_test = HTTPTest->new (input => \%urls, |
| 97 |
cmdline => $cmdline, |
| 98 |
errcode => $expected_error_code, |
| 99 |
output => \%expected_downloaded_files); |
| 100 |
exit $the_test->run(); |
| 101 |
|
| 102 |
# vim: et ts=4 sw=4 |