[wget-notify] COMMIT: r2333 - in /branches/bugs/b20323: src/ tests/
mtortonesi at ing.unife.it
mtortonesi at ing.unife.it
Fri Aug 10 06:43:16 PDT 2007
Author: mtortonesi
Date: Fri Aug 10 06:43:15 2007
New Revision: 2333
Log:
Fixed HTTP HEAD requests logic when --spider is given. Added tests to verify behaviour of --spider with every combination of -r option, --no-content-disposition option, and HTTP Content-Disposition header presence/absence.
Added:
branches/bugs/b20323/tests/Test--spider--no-content-disposition-trivial.px
branches/bugs/b20323/tests/Test--spider--no-content-disposition.px
branches/bugs/b20323/tests/Test--spider-HTTP-Content-Disposition.px
branches/bugs/b20323/tests/Test--spider-r--no-content-disposition-trivial.px
branches/bugs/b20323/tests/Test--spider-r--no-content-disposition.px
branches/bugs/b20323/tests/Test--spider-r-HTTP-Content-Disposition.px
Modified:
branches/bugs/b20323/src/ChangeLog
branches/bugs/b20323/src/http.c
branches/bugs/b20323/tests/ChangeLog
Modified: branches/bugs/b20323/src/ChangeLog
==============================================================================
--- branches/bugs/b20323/src/ChangeLog (original)
+++ branches/bugs/b20323/src/ChangeLog Fri Aug 10 06:43:15 2007
@@ -1,3 +1,8 @@
+2007-08-10 Mauro Tortonesi <mauro at ferrara.linux.it>
+
+ * http.c (http_loop): Fixed HTTP HEAD requests logic when --spider is
+ given.
+
2007-07-10 Mauro Tortonesi <mauro at ferrara.linux.it>
* http.c (http_loop): Fixed the HTTP requests logic. Now it skips the
Modified: branches/bugs/b20323/src/http.c
==============================================================================
--- branches/bugs/b20323/src/http.c (original)
+++ branches/bugs/b20323/src/http.c Fri Aug 10 06:43:15 2007
@@ -2303,9 +2303,10 @@
/* Reset the document type. */
*dt = 0;
- /* Skip preliminary HEAD request if -O or --no-content-disposition
- * are given */
- if (got_name || !opt.content_disposition)
+ /* Skip preliminary HEAD request if we're not in spider mode. Also skip it
+ * if -O was given or HTTP Content-Disposition support is disabled. */
+ if (!opt.spider
+ && (got_name || !opt.content_disposition))
send_head_first = false;
/* THE loop */
@@ -2349,8 +2350,7 @@
/* Default document type is empty. However, if spider mode is
on or time-stamping is employed, HEAD_ONLY commands is
encoded within *dt. */
- if (((opt.spider || opt.timestamping) && !got_head)
- || (send_head_first && !got_name))
+ if (send_head_first && !got_head)
*dt |= HEAD_ONLY;
else
*dt &= ~HEAD_ONLY;
@@ -2475,7 +2475,7 @@
}
/* Did we get the time-stamp? */
- if (!got_head)
+ if (send_head_first && !got_head)
{
bool restart_loop = false;
Modified: branches/bugs/b20323/tests/ChangeLog
==============================================================================
--- branches/bugs/b20323/tests/ChangeLog (original)
+++ branches/bugs/b20323/tests/ChangeLog Fri Aug 10 06:43:15 2007
@@ -1,3 +1,20 @@
+2007-08-10 Mauro Tortonesi <mauro at ferrara.linux.it>
+
+ * Test--spider--no-content-disposition-trivial.px: Added testing for
+ validation of HTTP request logic. In particular, they test whether the
+ preliminary HEAD request is skipped if --spider is given.
+
+ * Test--spider-r-HTTP-Content-Disposition.px: Ditto.
+
+ * Test--spider-HTTP-Content-Disposition.px: Ditto.
+
+ * Test--spider--no-content-disposition.px: Ditto.
+
+ * Test--spider-r--no-content-disposition-trivial.px: Ditto.
+
+ * Test--spider-r--no-content-disposition.px: Ditto.
+
+
2007-07-10 Mauro Tortonesi <mauro at ferrara.linux.it>
* Test--no-content-disposition.px: Added testing for validation of
Added: branches/bugs/b20323/tests/Test--spider--no-content-disposition-trivial.px
==============================================================================
--- branches/bugs/b20323/tests/Test--spider--no-content-disposition-trivial.px (added)
+++ branches/bugs/b20323/tests/Test--spider--no-content-disposition-trivial.px Fri Aug 10 06:43:15 2007
@@ -1,0 +1,52 @@
+#!/usr/bin/perl -w
+
+use strict;
+
+use HTTPTest;
+
+
+###############################################################################
+
+my $mainpage = <<EOF;
+<html>
+<head>
+ <title>Main Page</title>
+</head>
+<body>
+ <p>
+ Some text.
+ </p>
+</body>
+</html>
+EOF
+
+# code, msg, headers, content
+my %urls = (
+ '/index.html' => {
+ code => "200",
+ msg => "Dontcare",
+ headers => {
+ "Content-type" => "text/html",
+ },
+ content => $mainpage,
+ },
+);
+
+my $cmdline = "wget --spider --no-content-disposition http://localhost:8080/index.html";
+
+my $expected_error_code = 256;
+
+my %expected_downloaded_files = (
+);
+
+###############################################################################
+
+my $the_test = HTTPTest->new (name => "Test--spider--no-content-disposition-trivial",
+ input => \%urls,
+ cmdline => $cmdline,
+ errcode => $expected_error_code,
+ output => \%expected_downloaded_files);
+$the_test->run();
+
+# vim: et ts=4 sw=4
+
Added: branches/bugs/b20323/tests/Test--spider--no-content-disposition.px
==============================================================================
--- branches/bugs/b20323/tests/Test--spider--no-content-disposition.px (added)
+++ branches/bugs/b20323/tests/Test--spider--no-content-disposition.px Fri Aug 10 06:43:15 2007
@@ -1,0 +1,53 @@
+#!/usr/bin/perl -w
+
+use strict;
+
+use HTTPTest;
+
+
+###############################################################################
+
+my $mainpage = <<EOF;
+<html>
+<head>
+ <title>Main Page</title>
+</head>
+<body>
+ <p>
+ Some text.
+ </p>
+</body>
+</html>
+EOF
+
+# code, msg, headers, content
+my %urls = (
+ '/index.html' => {
+ code => "200",
+ msg => "Dontcare",
+ headers => {
+ "Content-type" => "text/html",
+ "Content-Disposition" => "attachment; filename=\"filename.html\"",
+ },
+ content => $mainpage,
+ },
+);
+
+my $cmdline = "wget --spider --no-content-disposition http://localhost:8080/index.html";
+
+my $expected_error_code = 256;
+
+my %expected_downloaded_files = (
+);
+
+###############################################################################
+
+my $the_test = HTTPTest->new (name => "Test--spider--no-content-disposition",
+ input => \%urls,
+ cmdline => $cmdline,
+ errcode => $expected_error_code,
+ output => \%expected_downloaded_files);
+$the_test->run();
+
+# vim: et ts=4 sw=4
+
Added: branches/bugs/b20323/tests/Test--spider-HTTP-Content-Disposition.px
==============================================================================
--- branches/bugs/b20323/tests/Test--spider-HTTP-Content-Disposition.px (added)
+++ branches/bugs/b20323/tests/Test--spider-HTTP-Content-Disposition.px Fri Aug 10 06:43:15 2007
@@ -1,0 +1,53 @@
+#!/usr/bin/perl -w
+
+use strict;
+
+use HTTPTest;
+
+
+###############################################################################
+
+my $mainpage = <<EOF;
+<html>
+<head>
+ <title>Main Page</title>
+</head>
+<body>
+ <p>
+ Some text.
+ </p>
+</body>
+</html>
+EOF
+
+# code, msg, headers, content
+my %urls = (
+ '/index.html' => {
+ code => "200",
+ msg => "Dontcare",
+ headers => {
+ "Content-type" => "text/html",
+ "Content-Disposition" => "attachment; filename=\"filename.html\"",
+ },
+ content => $mainpage,
+ },
+);
+
+my $cmdline = "wget --spider http://localhost:8080/index.html";
+
+my $expected_error_code = 256;
+
+my %expected_downloaded_files = (
+);
+
+###############################################################################
+
+my $the_test = HTTPTest->new (name => "Test--spider-HTTP-Content-Disposition",
+ input => \%urls,
+ cmdline => $cmdline,
+ errcode => $expected_error_code,
+ output => \%expected_downloaded_files);
+$the_test->run();
+
+# vim: et ts=4 sw=4
+
Added: branches/bugs/b20323/tests/Test--spider-r--no-content-disposition-trivial.px
==============================================================================
--- branches/bugs/b20323/tests/Test--spider-r--no-content-disposition-trivial.px (added)
+++ branches/bugs/b20323/tests/Test--spider-r--no-content-disposition-trivial.px Fri Aug 10 06:43:15 2007
@@ -1,0 +1,109 @@
+#!/usr/bin/perl -w
+
+use strict;
+
+use HTTPTest;
+
+
+###############################################################################
+
+my $mainpage = <<EOF;
+<html>
+<head>
+ <title>Main Page</title>
+</head>
+<body>
+ <p>
+ Some text and a link to a <a href="http://localhost:8080/secondpage.html">second page</a>.
+ Also, a <a href="http://localhost:8080/nonexistent">broken link</a>.
+ </p>
+</body>
+</html>
+EOF
+
+my $secondpage = <<EOF;
+<html>
+<head>
+ <title>Second Page</title>
+</head>
+<body>
+ <p>
+ Some text and a link to a <a href="http://localhost:8080/thirdpage.html">third page</a>.
+ Also, a <a href="http://localhost:8080/nonexistent">broken link</a>.
+ </p>
+</body>
+</html>
+EOF
+
+my $thirdpage = <<EOF;
+<html>
+<head>
+ <title>Third Page</title>
+</head>
+<body>
+ <p>
+ Some text and a link to a <a href="http://localhost:8080/dummy.txt">text file</a>.
+ Also, another <a href="http://localhost:8080/againnonexistent">broken link</a>.
+ </p>
+</body>
+</html>
+EOF
+
+my $dummyfile = <<EOF;
+Don't care.
+EOF
+
+# code, msg, headers, content
+my %urls = (
+ '/index.html' => {
+ code => "200",
+ msg => "Dontcare",
+ headers => {
+ "Content-type" => "text/html",
+ },
+ content => $mainpage,
+ },
+ '/secondpage.html' => {
+ code => "200",
+ msg => "Dontcare",
+ headers => {
+ "Content-type" => "text/html",
+ },
+ content => $secondpage,
+ },
+ '/thirdpage.html' => {
+ code => "200",
+ msg => "Dontcare",
+ headers => {
+ "Content-type" => "text/html",
+ },
+ content => $thirdpage,
+ },
+ '/dummy.txt' => {
+ code => "200",
+ msg => "Dontcare",
+ headers => {
+ "Content-type" => "text/plain",
+ },
+ content => $dummyfile
+ },
+);
+
+my $cmdline = "wget --spider -r --no-content-disposition http://localhost:8080/";
+
+my $expected_error_code = 0;
+
+my %expected_downloaded_files = (
+);
+
+###############################################################################
+
+my $the_test = HTTPTest->new (name => "Test--spider-r--no-content-disposition-trivial",
+ input => \%urls,
+ cmdline => $cmdline,
+ errcode => $expected_error_code,
+ output => \%expected_downloaded_files);
+$the_test->run();
+
+# vim: et ts=4 sw=4
+
Added: branches/bugs/b20323/tests/Test--spider-r--no-content-disposition.px
==============================================================================
--- branches/bugs/b20323/tests/Test--spider-r--no-content-disposition.px (added)
+++ branches/bugs/b20323/tests/Test--spider-r--no-content-disposition.px Fri Aug 10 06:43:15 2007
@@ -1,0 +1,110 @@
+#!/usr/bin/perl -w
+
+use strict;
+
+use HTTPTest;
+
+
+###############################################################################
+
+my $mainpage = <<EOF;
+<html>
+<head>
+ <title>Main Page</title>
+</head>
+<body>
+ <p>
+ Some text and a link to a <a href="http://localhost:8080/secondpage.html">second page</a>.
+ Also, a <a href="http://localhost:8080/nonexistent">broken link</a>.
+ </p>
+</body>
+</html>
+EOF
+
+my $secondpage = <<EOF;
+<html>
+<head>
+ <title>Second Page</title>
+</head>
+<body>
+ <p>
+ Some text and a link to a <a href="http://localhost:8080/thirdpage.html">third page</a>.
+ Also, a <a href="http://localhost:8080/nonexistent">broken link</a>.
+ </p>
+</body>
+</html>
+EOF
+
+my $thirdpage = <<EOF;
+<html>
+<head>
+ <title>Third Page</title>
+</head>
+<body>
+ <p>
+ Some text and a link to a <a href="http://localhost:8080/dummy.txt">text file</a>.
+ Also, another <a href="http://localhost:8080/againnonexistent">broken link</a>.
+ </p>
+</body>
+</html>
+EOF
+
+my $dummyfile = <<EOF;
+Don't care.
+EOF
+
+# code, msg, headers, content
+my %urls = (
+ '/index.html' => {
+ code => "200",
+ msg => "Dontcare",
+ headers => {
+ "Content-type" => "text/html",
+ },
+ content => $mainpage,
+ },
+ '/secondpage.html' => {
+ code => "200",
+ msg => "Dontcare",
+ headers => {
+ "Content-type" => "text/html",
+ "Content-Disposition" => "attachment; filename=\"filename.html\"",
+ },
+ content => $secondpage,
+ },
+ '/thirdpage.html' => {
+ code => "200",
+ msg => "Dontcare",
+ headers => {
+ "Content-type" => "text/html",
+ },
+ content => $thirdpage,
+ },
+ '/dummy.txt' => {
+ code => "200",
+ msg => "Dontcare",
+ headers => {
+ "Content-type" => "text/plain",
+ },
+ content => $dummyfile
+ },
+);
+
+my $cmdline = "wget --spider -r --no-content-disposition http://localhost:8080/";
+
+my $expected_error_code = 0;
+
+my %expected_downloaded_files = (
+);
+
+###############################################################################
+
+my $the_test = HTTPTest->new (name => "Test--spider-r--no-content-disposition",
+ input => \%urls,
+ cmdline => $cmdline,
+ errcode => $expected_error_code,
+ output => \%expected_downloaded_files);
+$the_test->run();
+
+# vim: et ts=4 sw=4
+
Added: branches/bugs/b20323/tests/Test--spider-r-HTTP-Content-Disposition.px
==============================================================================
--- branches/bugs/b20323/tests/Test--spider-r-HTTP-Content-Disposition.px (added)
+++ branches/bugs/b20323/tests/Test--spider-r-HTTP-Content-Disposition.px Fri Aug 10 06:43:15 2007
@@ -1,0 +1,110 @@
+#!/usr/bin/perl -w
+
+use strict;
+
+use HTTPTest;
+
+
+###############################################################################
+
+my $mainpage = <<EOF;
+<html>
+<head>
+ <title>Main Page</title>
+</head>
+<body>
+ <p>
+ Some text and a link to a <a href="http://localhost:8080/secondpage.html">second page</a>.
+ Also, a <a href="http://localhost:8080/nonexistent">broken link</a>.
+ </p>
+</body>
+</html>
+EOF
+
+my $secondpage = <<EOF;
+<html>
+<head>
+ <title>Second Page</title>
+</head>
+<body>
+ <p>
+ Some text and a link to a <a href="http://localhost:8080/thirdpage.html">third page</a>.
+ Also, a <a href="http://localhost:8080/nonexistent">broken link</a>.
+ </p>
+</body>
+</html>
+EOF
+
+my $thirdpage = <<EOF;
+<html>
+<head>
+ <title>Third Page</title>
+</head>
+<body>
+ <p>
+ Some text and a link to a <a href="http://localhost:8080/dummy.txt">text file</a>.
+ Also, another <a href="http://localhost:8080/againnonexistent">broken link</a>.
+ </p>
+</body>
+</html>
+EOF
+
+my $dummyfile = <<EOF;
+Don't care.
+EOF
+
+# code, msg, headers, content
+my %urls = (
+ '/index.html' => {
+ code => "200",
+ msg => "Dontcare",
+ headers => {
+ "Content-type" => "text/html",
+ },
+ content => $mainpage,
+ },
+ '/secondpage.html' => {
+ code => "200",
+ msg => "Dontcare",
+ headers => {
+ "Content-type" => "text/html",
+ "Content-Disposition" => "attachment; filename=\"filename.html\"",
+ },
+ content => $secondpage,
+ },
+ '/thirdpage.html' => {
+ code => "200",
+ msg => "Dontcare",
+ headers => {
+ "Content-type" => "text/html",
+ },
+ content => $thirdpage,
+ },
+ '/dummy.txt' => {
+ code => "200",
+ msg => "Dontcare",
+ headers => {
+ "Content-type" => "text/plain",
+ },
+ content => $dummyfile
+ },
+);
+
+my $cmdline = "wget --spider -r http://localhost:8080/";
+
+my $expected_error_code = 0;
+
+my %expected_downloaded_files = (
+);
+
+###############################################################################
+
+my $the_test = HTTPTest->new (name => "Test--spider-r-HTTP-Content-Disposition",
+ input => \%urls,
+ cmdline => $cmdline,
+ errcode => $expected_error_code,
+ output => \%expected_downloaded_files);
+$the_test->run();
+
+# vim: et ts=4 sw=4
+
More information about the wget-notify
mailing list