2010-06-04 17:12:19 +08:00
|
|
|
#!/usr/bin/env perl
|
2006-11-10 19:06:24 +08:00
|
|
|
|
|
|
|
use strict;
|
2008-11-13 05:54:49 +08:00
|
|
|
use warnings;
|
2006-11-10 19:06:24 +08:00
|
|
|
|
|
|
|
use HTTPTest;
|
|
|
|
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
|
|
|
|
my $mainpage = <<EOF;
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<title>Main Page</title>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<p>
|
2008-06-12 17:18:35 +08:00
|
|
|
Some text and a link to a <a href="http://localhost:{{port}}/firstlevel/secondpage.html">second page</a>.
|
2006-11-10 19:06:24 +08:00
|
|
|
</p>
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
EOF
|
|
|
|
|
|
|
|
my $secondpage = <<EOF;
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<title>Second Page</title>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<p>
|
2008-06-12 17:18:35 +08:00
|
|
|
Some text and a link to a <a href="http://localhost:{{port}}/firstlevel/lowerlevel/thirdpage.html">third page</a>.
|
2006-11-10 19:06:24 +08:00
|
|
|
</p>
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
EOF
|
|
|
|
|
|
|
|
my $thirdpage = <<EOF;
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<title>Third Page</title>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<p>
|
2008-06-12 17:18:35 +08:00
|
|
|
Some text and a link to a <a href="http://localhost:{{port}}/higherlevelpage.html">higher level page</a>.
|
2006-11-10 19:06:24 +08:00
|
|
|
</p>
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
EOF
|
|
|
|
|
|
|
|
my $fourthpage = <<EOF;
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<title>Fourth Page</title>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<p>
|
|
|
|
This page is only linked by the higher level page. Therefore, it should not
|
2009-09-22 11:39:44 +08:00
|
|
|
be downloaded.
|
2006-11-10 19:06:24 +08:00
|
|
|
</p>
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
EOF
|
|
|
|
|
|
|
|
my $higherlevelpage = <<EOF;
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<title>Higher Level Page</title>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<p>
|
|
|
|
This page is on a higher level in the URL path hierarchy. Therefore, it
|
2009-09-22 11:39:44 +08:00
|
|
|
should not be downloaded. Wget should not visit the following link to a
|
2008-06-12 17:18:35 +08:00
|
|
|
<a href="http://localhost:{{port}}/firstlevel/fourthpage.html">fourth page</a>.
|
2006-11-10 19:06:24 +08:00
|
|
|
</p>
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
EOF
|
|
|
|
|
|
|
|
# code, msg, headers, content
|
|
|
|
my %urls = (
|
2006-12-27 17:00:12 +08:00
|
|
|
'/firstlevel/index.html' => {
|
2006-11-10 19:06:24 +08:00
|
|
|
code => "200",
|
|
|
|
msg => "Dontcare",
|
|
|
|
headers => {
|
|
|
|
"Content-type" => "text/html",
|
|
|
|
},
|
|
|
|
content => $mainpage,
|
|
|
|
},
|
2006-12-27 17:00:12 +08:00
|
|
|
'/firstlevel/secondpage.html' => {
|
2006-11-10 19:06:24 +08:00
|
|
|
code => "200",
|
|
|
|
msg => "Dontcare",
|
|
|
|
headers => {
|
|
|
|
"Content-type" => "text/html",
|
|
|
|
},
|
|
|
|
content => $secondpage,
|
|
|
|
},
|
2006-12-27 17:00:12 +08:00
|
|
|
'/firstlevel/lowerlevel/thirdpage.html' => {
|
2006-11-10 19:06:24 +08:00
|
|
|
code => "200",
|
|
|
|
msg => "Dontcare",
|
|
|
|
headers => {
|
|
|
|
"Content-type" => "text/html",
|
|
|
|
},
|
|
|
|
content => $thirdpage,
|
|
|
|
},
|
2006-12-27 17:00:12 +08:00
|
|
|
'/firstlevel/fourthpage.html' => {
|
2006-11-10 19:06:24 +08:00
|
|
|
code => "200",
|
|
|
|
msg => "Dontcare",
|
|
|
|
headers => {
|
|
|
|
"Content-type" => "text/plain",
|
|
|
|
},
|
|
|
|
content => $fourthpage,
|
|
|
|
},
|
2006-12-27 17:00:12 +08:00
|
|
|
'/higherlevelpage.html' => {
|
2006-11-10 19:06:24 +08:00
|
|
|
code => "200",
|
|
|
|
msg => "Dontcare",
|
|
|
|
headers => {
|
|
|
|
"Content-type" => "text/plain",
|
|
|
|
},
|
|
|
|
content => $higherlevelpage,
|
|
|
|
},
|
|
|
|
);
|
|
|
|
|
2008-06-12 17:18:35 +08:00
|
|
|
my $cmdline = $WgetTest::WGETPATH . " -np -nH -r http://localhost:{{port}}/firstlevel/";
|
2006-11-10 19:06:24 +08:00
|
|
|
|
|
|
|
my $expected_error_code = 0;
|
|
|
|
|
|
|
|
my %expected_downloaded_files = (
|
|
|
|
'firstlevel/index.html' => {
|
|
|
|
content => $mainpage,
|
|
|
|
},
|
|
|
|
'firstlevel/secondpage.html' => {
|
|
|
|
content => $secondpage,
|
|
|
|
},
|
|
|
|
'firstlevel/lowerlevel/thirdpage.html' => {
|
|
|
|
content => $thirdpage,
|
|
|
|
},
|
|
|
|
);
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
|
|
|
|
my $the_test = HTTPTest->new (name => "Test-np",
|
2009-09-22 11:39:44 +08:00
|
|
|
input => \%urls,
|
|
|
|
cmdline => $cmdline,
|
|
|
|
errcode => $expected_error_code,
|
2006-11-10 19:06:24 +08:00
|
|
|
output => \%expected_downloaded_files);
|
2007-07-12 14:10:48 +08:00
|
|
|
exit $the_test->run();
|
2006-11-10 19:06:24 +08:00
|
|
|
|
|
|
|
# vim: et ts=4 sw=4
|