| 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 |
|
| 13 |
############################################################################### |
| 14 |
|
| 15 |
my $starter_file = <<EOF; |
| 16 |
<a href="http://$euc_jp_hostname/">The link</a> |
| 17 |
EOF |
| 18 |
|
| 19 |
my $result_file = <<EOF; |
| 20 |
Found me! |
| 21 |
EOF |
| 22 |
|
| 23 |
# code, msg, headers, content |
| 24 |
my %urls = ( |
| 25 |
'http://start-here.com/start.html' => { |
| 26 |
code => "200", |
| 27 |
msg => "You want fries with that?", |
| 28 |
headers => { |
| 29 |
'Content-Type' => 'text/html; charset=EUC-JP', |
| 30 |
}, |
| 31 |
content => $starter_file, |
| 32 |
}, |
| 33 |
"http://$punycoded_hostname/index.html" => { |
| 34 |
code => "200", |
| 35 |
msg => "Yes, please", |
| 36 |
headers => { |
| 37 |
'Content-Type' => 'text/plain', |
| 38 |
}, |
| 39 |
content => $result_file, |
| 40 |
}, |
| 41 |
); |
| 42 |
|
| 43 |
my $cmdline = $WgetTest::WGETPATH . " --iri -rH" |
| 44 |
. " -e http_proxy=localhost:{{port}} http://start-here.com/start.html"; |
| 45 |
|
| 46 |
my $expected_error_code = 0; |
| 47 |
|
| 48 |
my %expected_downloaded_files = ( |
| 49 |
'start-here.com/start.html' => { |
| 50 |
content => $starter_file, |
| 51 |
}, |
| 52 |
"$punycoded_hostname/index.html" => { |
| 53 |
content => $result_file, |
| 54 |
}, |
| 55 |
); |
| 56 |
|
| 57 |
############################################################################### |
| 58 |
|
| 59 |
my $the_test = HTTPTest->new (input => \%urls, |
| 60 |
cmdline => $cmdline, |
| 61 |
errcode => $expected_error_code, |
| 62 |
output => \%expected_downloaded_files); |
| 63 |
exit $the_test->run(); |
| 64 |
|
| 65 |
# vim: et ts=4 sw=4 |