]> sjero.net Git - wget/commitdiff
[svn] Fix #20323 - Adjustments and tests for when HEAD should be sent.
authormicah <devnull@localhost>
Thu, 30 Aug 2007 04:16:24 +0000 (21:16 -0700)
committermicah <devnull@localhost>
Thu, 30 Aug 2007 04:16:24 +0000 (21:16 -0700)
18 files changed:
src/ChangeLog
src/http.c
tests/ChangeLog
tests/Makefile.in
tests/Test--no-content-disposition-trivial.px [new file with mode: 0755]
tests/Test--no-content-disposition.px [new file with mode: 0755]
tests/Test--spider--no-content-disposition-trivial.px [new file with mode: 0755]
tests/Test--spider--no-content-disposition.px [new file with mode: 0755]
tests/Test--spider-HTTP-Content-Disposition.px [new file with mode: 0755]
tests/Test--spider-r--no-content-disposition-trivial.px [new file with mode: 0755]
tests/Test--spider-r--no-content-disposition.px [new file with mode: 0755]
tests/Test--spider-r-HTTP-Content-Disposition.px [new file with mode: 0755]
tests/Test-N--no-content-disposition-trivial.px [new file with mode: 0755]
tests/Test-N--no-content-disposition.px [new file with mode: 0755]
tests/Test-N-HTTP-Content-Disposition.px [new file with mode: 0755]
tests/Test-O--no-content-disposition-trivial.px [new file with mode: 0755]
tests/Test-O--no-content-disposition.px [new file with mode: 0755]
tests/Test-O-HTTP-Content-Disposition.px [new file with mode: 0755]

index be8233efefe5d5ccf2872a12a23df864f4000736..d8f2fa97d148ca4626548c7763031f59559b9e55 100644 (file)
 
        * spider.c (in_url_list_p): Removed the bool verbose argument
 
 
        * spider.c (in_url_list_p): Removed the bool verbose argument
 
+2007-08-22  Mauro Tortonesi  <mauro@ferrara.linux.it>
+
+       * http.c (http_loop): Fall back to GET if HEAD fails with a 500 or 501
+       error code.
+
+2007-08-21  Mauro Tortonesi  <mauro@ferrara.linux.it>
+       
+       * http.c (http_loop): Send preliminary HEAD request if -N is given and
+       the destination file exists already.
+
+2007-08-10  Mauro Tortonesi  <mauro@ferrara.linux.it>
+
+       * http.c (http_loop): Fixed HTTP HEAD requests logic when --spider is
+       given.
+
 2007-08-10  Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
 
        * url.c (append_uri_pathel): Do not assume dest string to be
 2007-08-10  Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
 
        * url.c (append_uri_pathel): Do not assume dest string to be
        * test.h: tests made more verbose; now displays the name
        of each test run.
 
        * test.h: tests made more verbose; now displays the name
        of each test run.
 
+2007-07-10  Mauro Tortonesi  <mauro@ferrara.linux.it>
+
+       * http.c (http_loop): Fixed the HTTP requests logic. Now it skips the 
+       preliminary HEAD request if either -O or --no-content-disposition are 
+       given, and neither --spider and -N are given.
+
 2007-07-05  Micah Cowan  <micah@cowan.name>
 
        * cmpt.c, connect.c, connect.h, convert.c, convert.h:
 2007-07-05  Micah Cowan  <micah@cowan.name>
 
        * cmpt.c, connect.c, connect.h, convert.c, convert.h:
        Updated GPL reference to version 3 or later, removed FSF
        address.
 
        Updated GPL reference to version 3 or later, removed FSF
        address.
 
+2007-07-04  Mauro Tortonesi  <mauro@ferrara.linux.it>
+
+       * http.c (http_loop): Skip HEAD request and start immediately with GET
+       if -O is given.
+
 2007-02-02  Hrvoje Niksic  <hniksic@xemacs.org>
 
        * http.c (print_server_response): Escape non-printable characters
 2007-02-02  Hrvoje Niksic  <hniksic@xemacs.org>
 
        * http.c (print_server_response): Escape non-printable characters
index 414e8e696d39aeb8e52ebf7c32ca2a170ef2c235..0dec22358256d813841196821a498e9c3221d3fa 100644 (file)
@@ -2314,6 +2314,7 @@ http_loop (struct url *u, char **newloc, char **local_file, const char *referer,
   wgint local_size = 0;          /* the size of the local file */
   struct http_stat hstat;        /* HTTP status */
   struct_stat st;  
   wgint local_size = 0;          /* the size of the local file */
   struct http_stat hstat;        /* HTTP status */
   struct_stat st;  
+  bool send_head_first = true;
 
   /* Assert that no value for *LOCAL_FILE was passed. */
   assert (local_file == NULL || *local_file == NULL);
 
   /* Assert that no value for *LOCAL_FILE was passed. */
   assert (local_file == NULL || *local_file == NULL);
@@ -2351,6 +2352,19 @@ http_loop (struct url *u, char **newloc, char **local_file, const char *referer,
   /* Reset the document type. */
   *dt = 0;
   
   /* Reset the document type. */
   *dt = 0;
   
+  /* Skip preliminary HEAD request if we're not in spider mode AND
+   * if -O was given or HTTP Content-Disposition support is disabled. */
+  if (!opt.spider
+      && (got_name || !opt.content_disposition))
+    send_head_first = false;
+
+  /* Send preliminary HEAD request if -N is given and we have an existing 
+   * destination file. */
+  if (opt.timestamping 
+      && !opt.content_disposition
+      && file_exists_p (url_file_name (u)))
+    send_head_first = true;
+  
   /* THE loop */
   do
     {
   /* THE loop */
   do
     {
@@ -2392,8 +2406,7 @@ Spider mode enabled. Check if remote file exists.\n"));
       /* Default document type is empty.  However, if spider mode is
          on or time-stamping is employed, HEAD_ONLY commands is
          encoded within *dt.  */
       /* 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)
-          || (opt.always_rest && !got_name))
+      if (send_head_first && !got_head) 
         *dt |= HEAD_ONLY;
       else
         *dt &= ~HEAD_ONLY;
         *dt |= HEAD_ONLY;
       else
         *dt &= ~HEAD_ONLY;
@@ -2434,7 +2447,7 @@ Spider mode enabled. Check if remote file exists.\n"));
       /* Get the new location (with or without the redirection).  */
       if (hstat.newloc)
         *newloc = xstrdup (hstat.newloc);
       /* Get the new location (with or without the redirection).  */
       if (hstat.newloc)
         *newloc = xstrdup (hstat.newloc);
-      
+
       switch (err)
         {
         case HERR: case HEOF: case CONSOCKERR: case CONCLOSED:
       switch (err)
         {
         case HERR: case HEOF: case CONSOCKERR: case CONCLOSED:
@@ -2485,7 +2498,7 @@ Spider mode enabled. Check if remote file exists.\n"));
           /* All possibilities should have been exhausted.  */
           abort ();
         }
           /* All possibilities should have been exhausted.  */
           abort ();
         }
-     
+      
       if (!(*dt & RETROKF))
         {
           char *hurl = NULL;
       if (!(*dt & RETROKF))
         {
           char *hurl = NULL;
@@ -2495,9 +2508,17 @@ Spider mode enabled. Check if remote file exists.\n"));
               hurl = url_string (u, URL_AUTH_HIDE_PASSWD);
               logprintf (LOG_NONVERBOSE, "%s:\n", hurl);
             }
               hurl = url_string (u, URL_AUTH_HIDE_PASSWD);
               logprintf (LOG_NONVERBOSE, "%s:\n", hurl);
             }
+
+          /* Fall back to GET if HEAD fails with a 500 or 501 error code. */
+          if (*dt & HEAD_ONLY
+              && (hstat.statcode == 500 || hstat.statcode == 501))
+            {
+              got_head = true;
+              continue;
+            }
           /* Maybe we should always keep track of broken links, not just in
            * spider mode.  */
           /* Maybe we should always keep track of broken links, not just in
            * spider mode.  */
-          if (opt.spider)
+          else if (opt.spider)
             {
               /* #### Again: ugly ugly ugly! */
               if (!hurl) 
             {
               /* #### Again: ugly ugly ugly! */
               if (!hurl) 
@@ -2518,7 +2539,7 @@ Remote file does not exist -- broken link!!!\n"));
         }
 
       /* Did we get the time-stamp? */
         }
 
       /* Did we get the time-stamp? */
-      if (!got_head)
+      if (send_head_first && !got_head)
         {
           bool restart_loop = false;
 
         {
           bool restart_loop = false;
 
@@ -2584,12 +2605,6 @@ The sizes do not match (local %s) -- retrieving.\n"),
               restart_loop = true;
             }
           
               restart_loop = true;
             }
           
-          if (opt.always_rest)
-            {
-              got_name = true;
-              restart_loop = true;
-            }
-          
           if (opt.spider)
             {
               if (opt.recursive)
           if (opt.spider)
             {
               if (opt.recursive)
@@ -2617,6 +2632,12 @@ Remote file exists but recursion is disabled -- not retrieving.\n\n"));
                 }
             }
 
                 }
             }
 
+          if (send_head_first)
+            {
+              got_name = true;
+              restart_loop = true;
+            }
+          
           got_head = true;    /* no more time-stamping */
           *dt &= ~HEAD_ONLY;
           count = 0;          /* the retrieve count for HEAD is reset */
           got_head = true;    /* no more time-stamping */
           *dt &= ~HEAD_ONLY;
           count = 0;          /* the retrieve count for HEAD is reset */
index c5b42778efbeedef1afed51c24422c3bdf08dbea..b80fa17dcd4d4bc8899093a1bfe9069782d80887 100644 (file)
@@ -1,17 +1,34 @@
 2007-08-21  Mauro Tortonesi  <mauro@ferrara.linux.it>
 
 2007-08-21  Mauro Tortonesi  <mauro@ferrara.linux.it>
 
-        * WgetTest.pm.in: Added support for timestamping of pre-existing
-        files.
+       * WgetTest.pm.in: Added support for timestamping of pre-existing
+       files.
 
 
-        * Test-N-current.px: Fixed broken test logic.
+       * Test-N-current.px: Fixed broken test logic.
 
        * Makefile.in: Updated list of automatically run tests.
 
 
        * Makefile.in: Updated list of automatically run tests.
 
-        * Test-HTTP-Content-Disposition.px: Added -e contentdisposition=on
-        option, since now HTTP Content-Disposition header support is turned
-        off by default.
+       * Test-HTTP-Content-Disposition.px: Added -e contentdisposition=on
+       option, since now HTTP Content-Disposition header support is turned
+       off by default.
 
 
-        * Test-HTTP-Content-Disposition-1.px: Ditto.
+       * Test-HTTP-Content-Disposition-1.px: Ditto.
+
+2007-08-10  Mauro Tortonesi  <mauro@ferrara.linux.it>
+
+       * Test--spider--no-content-disposition-trivial.px: Added new tests for
+       validation of HTTP Content-Disposition header support logic. In
+       particular, these tests check wget's behavior for every combination of
+       --spider [-r] and -e contentdisposition=on/off options.
+
+       * 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-25  Micah Cowan  <micah@cowan.name>
 
 
 2007-07-25  Micah Cowan  <micah@cowan.name>
 
        ensure that correct basic creds are sent, but never until a
        challenge has been sent.
 
        ensure that correct basic creds are sent, but never until a
        challenge has been sent.
 
+2007-07-10  Mauro Tortonesi  <mauro@ferrara.linux.it>
+
+       * Test--no-content-disposition.px: Added new tests for validation of
+       HTTP Content-Disposition header support logic. In particular, these
+       tests check wget's behavior for every combination of -N/-O and -e
+       contentdisposition=on/off options.
+
+       * Test--no-content-disposition-trivial.px: Ditto.
+
+       * Test-N-HTTP-Content-Disposition.px: Ditto.
+
+       * Test-N--no-content-disposition.px: Ditto.
+
+       * Test-N--no-content-disposition-trivial.px: Ditto.
+
+       * Test-O-HTTP-Content-Disposition.px: Ditto.
+
+       * Test-O--no-content-disposition.px: Ditto.
+
+       * Test-O--no-content-disposition-trivial.px: Ditto.
+
 2007-07-05  Micah Cowan  <micah@cowan.name>
 
        * Makefile.in:
 2007-07-05  Micah Cowan  <micah@cowan.name>
 
        * Makefile.in:
index 21d7641064a314ab87acadac83e838d8d05c5b94..7e7eff7a555443100d1f369d81b89da9c56b98ab 100644 (file)
@@ -95,18 +95,33 @@ run-px-tests: WgetTest.pm
        ./Test-HTTP-Content-Disposition-1.px && echo && echo
        ./Test-HTTP-Content-Disposition-2.px && echo && echo
        ./Test-HTTP-Content-Disposition.px && echo && echo
        ./Test-HTTP-Content-Disposition-1.px && echo && echo
        ./Test-HTTP-Content-Disposition-2.px && echo && echo
        ./Test-HTTP-Content-Disposition.px && echo && echo
+       ./Test-N-current-HTTP-CD.px && echo && echo
        ./Test-N-current.px && echo && echo
        ./Test-N-current.px && echo && echo
+       ./Test-N-HTTP-Content-Disposition.px && echo && echo
+       ./Test-N--no-content-disposition.px && echo && echo
+       ./Test-N--no-content-disposition-trivial.px && echo && echo
+       ./Test--no-content-disposition.px && echo && echo
+       ./Test--no-content-disposition-trivial.px && echo && echo
        ./Test-N-old.px && echo && echo
        ./Test-nonexisting-quiet.px && echo && echo
        ./Test-noop.px && echo && echo
        ./Test-np.px && echo && echo
        ./Test-N.px && echo && echo
        ./Test-N-old.px && echo && echo
        ./Test-nonexisting-quiet.px && echo && echo
        ./Test-noop.px && echo && echo
        ./Test-np.px && echo && echo
        ./Test-N.px && echo && echo
+       ./Test-O-HTTP-Content-Disposition.px && echo && echo
+       ./Test-O--no-content-disposition.px && echo && echo
+       ./Test-O--no-content-disposition-trivial.px && echo && echo
        ./Test-O-nonexisting.px && echo && echo
        ./Test-O.px && echo && echo
        ./Test-Restrict-Lowercase.px && echo && echo
        ./Test-Restrict-Uppercase.px && echo && echo
        ./Test--spider-fail.px && echo && echo
        ./Test-O-nonexisting.px && echo && echo
        ./Test-O.px && echo && echo
        ./Test-Restrict-Lowercase.px && echo && echo
        ./Test-Restrict-Uppercase.px && echo && echo
        ./Test--spider-fail.px && echo && echo
+       ./Test--spider-HTTP-Content-Disposition.px && echo && echo
+       ./Test--spider--no-content-disposition.px && echo && echo
+       ./Test--spider--no-content-disposition-trivial.px && echo && echo
        ./Test--spider.px && echo && echo
        ./Test--spider.px && echo && echo
+       ./Test--spider-r-HTTP-Content-Disposition.px && echo && echo
+       ./Test--spider-r--no-content-disposition.px && echo && echo
+       ./Test--spider-r--no-content-disposition-trivial.px && echo && echo
        ./Test--spider-r.px && echo && echo
 
 WgetTest.pm: WgetTest.pm.in @top_srcdir@/config.status
        ./Test--spider-r.px && echo && echo
 
 WgetTest.pm: WgetTest.pm.in @top_srcdir@/config.status
diff --git a/tests/Test--no-content-disposition-trivial.px b/tests/Test--no-content-disposition-trivial.px
new file mode 100755 (executable)
index 0000000..1d64125
--- /dev/null
@@ -0,0 +1,55 @@
+#!/usr/bin/perl -w
+
+use strict;
+
+use HTTPTest;
+
+
+###############################################################################
+
+my $dummyfile = <<EOF;
+<html>
+<head>
+  <title>Page Title</title>
+</head>
+<body>
+  <p>
+    Some text.
+  </p>
+</body>
+</html>
+EOF
+
+# code, msg, headers, content
+my %urls = (
+    '/dummy.html' => {
+        code => "200",
+        msg => "Dontcare",
+        headers => {
+            "Content-type" => "text/html",
+        },
+        content => $dummyfile,
+    },
+);
+
+my $cmdline = $WgetTest::WGETPATH . " --no-content-disposition http://localhost:8080/dummy.html";
+
+my $expected_error_code = 0;
+
+my %expected_downloaded_files = (
+    'dummy.html' => {
+        content => $dummyfile,
+    }
+);
+
+###############################################################################
+
+my $the_test = HTTPTest->new (name => "Test--no-content-disposition-trivial",
+                              input => \%urls, 
+                              cmdline => $cmdline, 
+                              errcode => $expected_error_code, 
+                              output => \%expected_downloaded_files);
+exit $the_test->run();
+
+# vim: et ts=4 sw=4
+
diff --git a/tests/Test--no-content-disposition.px b/tests/Test--no-content-disposition.px
new file mode 100755 (executable)
index 0000000..d5433f0
--- /dev/null
@@ -0,0 +1,56 @@
+#!/usr/bin/perl -w
+
+use strict;
+
+use HTTPTest;
+
+
+###############################################################################
+
+my $dummyfile = <<EOF;
+<html>
+<head>
+  <title>Page Title</title>
+</head>
+<body>
+  <p>
+    Some text.
+  </p>
+</body>
+</html>
+EOF
+
+# code, msg, headers, content
+my %urls = (
+    '/dummy.html' => {
+        code => "200",
+        msg => "Dontcare",
+        headers => {
+            "Content-type" => "text/html",
+            "Content-Disposition" => "attachment; filename=\"filename.html\"",
+        },
+        content => $dummyfile,
+    },
+);
+
+my $cmdline = $WgetTest::WGETPATH . " --no-content-disposition http://localhost:8080/dummy.html";
+
+my $expected_error_code = 0;
+
+my %expected_downloaded_files = (
+    'dummy.html' => {
+        content => $dummyfile,
+    }
+);
+
+###############################################################################
+
+my $the_test = HTTPTest->new (name => "Test--no-content-disposition",
+                              input => \%urls, 
+                              cmdline => $cmdline, 
+                              errcode => $expected_error_code, 
+                              output => \%expected_downloaded_files);
+exit $the_test->run();
+
+# vim: et ts=4 sw=4
+
diff --git a/tests/Test--spider--no-content-disposition-trivial.px b/tests/Test--spider--no-content-disposition-trivial.px
new file mode 100755 (executable)
index 0000000..323db07
--- /dev/null
@@ -0,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 = $WgetTest::WGETPATH . " --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);
+exit $the_test->run();
+
+# vim: et ts=4 sw=4
+
diff --git a/tests/Test--spider--no-content-disposition.px b/tests/Test--spider--no-content-disposition.px
new file mode 100755 (executable)
index 0000000..acf73a7
--- /dev/null
@@ -0,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 = $WgetTest::WGETPATH . " --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);
+exit $the_test->run();
+
+# vim: et ts=4 sw=4
+
diff --git a/tests/Test--spider-HTTP-Content-Disposition.px b/tests/Test--spider-HTTP-Content-Disposition.px
new file mode 100755 (executable)
index 0000000..79eaba5
--- /dev/null
@@ -0,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 = $WgetTest::WGETPATH . " --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);
+exit $the_test->run();
+
+# vim: et ts=4 sw=4
+
diff --git a/tests/Test--spider-r--no-content-disposition-trivial.px b/tests/Test--spider-r--no-content-disposition-trivial.px
new file mode 100755 (executable)
index 0000000..0e290c2
--- /dev/null
@@ -0,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 = $WgetTest::WGETPATH . " --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);
+exit $the_test->run();
+
+# vim: et ts=4 sw=4
+
diff --git a/tests/Test--spider-r--no-content-disposition.px b/tests/Test--spider-r--no-content-disposition.px
new file mode 100755 (executable)
index 0000000..0e3c00e
--- /dev/null
@@ -0,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 = $WgetTest::WGETPATH . " --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);
+exit $the_test->run();
+
+# vim: et ts=4 sw=4
+
diff --git a/tests/Test--spider-r-HTTP-Content-Disposition.px b/tests/Test--spider-r-HTTP-Content-Disposition.px
new file mode 100755 (executable)
index 0000000..e70f6b4
--- /dev/null
@@ -0,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 = $WgetTest::WGETPATH . " --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);
+exit $the_test->run();
+
+# vim: et ts=4 sw=4
+
diff --git a/tests/Test-N--no-content-disposition-trivial.px b/tests/Test-N--no-content-disposition-trivial.px
new file mode 100755 (executable)
index 0000000..390d369
--- /dev/null
@@ -0,0 +1,48 @@
+#!/usr/bin/perl -w
+
+use strict;
+
+use HTTPTest;
+
+
+###############################################################################
+
+my $dummyfile = <<EOF;
+Content
+EOF
+
+# code, msg, headers, content
+my %urls = (
+    '/dummy.txt' => {
+        code => "200",
+        msg => "Dontcare",
+        headers => {
+            "Content-type" => "text/plain",
+            "Last-Modified" => "Sat, 09 Oct 2004 08:30:00 GMT",
+        },
+        content => $dummyfile
+    },
+);
+
+my $cmdline = $WgetTest::WGETPATH . " -N --no-content-disposition http://localhost:8080/dummy.txt";
+
+my $expected_error_code = 0;
+
+my %expected_downloaded_files = (
+    'dummy.txt' => {
+        content => $dummyfile,
+        timestamp => 1097310600, # "Sat, 09 Oct 2004 08:30:00 GMT"
+    }
+);
+
+###############################################################################
+
+my $the_test = HTTPTest->new (name => "Test-N--no-content-disposition-trivial",
+                              input => \%urls, 
+                              cmdline => $cmdline, 
+                              errcode => $expected_error_code, 
+                              output => \%expected_downloaded_files);
+exit $the_test->run();
+
+# vim: et ts=4 sw=4
+
diff --git a/tests/Test-N--no-content-disposition.px b/tests/Test-N--no-content-disposition.px
new file mode 100755 (executable)
index 0000000..dbec7c6
--- /dev/null
@@ -0,0 +1,49 @@
+#!/usr/bin/perl -w
+
+use strict;
+
+use HTTPTest;
+
+
+###############################################################################
+
+my $dummyfile = <<EOF;
+Content
+EOF
+
+# code, msg, headers, content
+my %urls = (
+    '/dummy.txt' => {
+        code => "200",
+        msg => "Dontcare",
+        headers => {
+            "Content-type" => "text/plain",
+            "Last-Modified" => "Sat, 09 Oct 2004 08:30:00 GMT",
+            "Content-Disposition" => "attachment; filename=\"filename.txt\"",
+        },
+        content => $dummyfile
+    },
+);
+
+my $cmdline = $WgetTest::WGETPATH . " -N --no-content-disposition http://localhost:8080/dummy.txt";
+
+my $expected_error_code = 0;
+
+my %expected_downloaded_files = (
+    'dummy.txt' => {
+        content => $dummyfile,
+        timestamp => 1097310600, # "Sat, 09 Oct 2004 08:30:00 GMT"
+    }
+);
+
+###############################################################################
+
+my $the_test = HTTPTest->new (name => "Test-N--no-content-disposition",
+                              input => \%urls, 
+                              cmdline => $cmdline, 
+                              errcode => $expected_error_code, 
+                              output => \%expected_downloaded_files);
+exit $the_test->run();
+
+# vim: et ts=4 sw=4
+
diff --git a/tests/Test-N-HTTP-Content-Disposition.px b/tests/Test-N-HTTP-Content-Disposition.px
new file mode 100755 (executable)
index 0000000..8c5e418
--- /dev/null
@@ -0,0 +1,49 @@
+#!/usr/bin/perl -w
+
+use strict;
+
+use HTTPTest;
+
+
+###############################################################################
+
+my $dummyfile = <<EOF;
+Don't care.
+EOF
+
+# code, msg, headers, content
+my %urls = (
+    '/dummy.txt' => {
+        code => "200",
+        msg => "Dontcare",
+        headers => {
+            "Content-type" => "text/plain",
+            "Last-Modified" => "Sat, 09 Oct 2004 08:30:00 GMT",
+            "Content-Disposition" => "attachment; filename=\"filename.txt\"",
+        },
+        content => $dummyfile
+    },
+);
+
+my $cmdline = $WgetTest::WGETPATH . " -N http://localhost:8080/dummy.txt";
+
+my $expected_error_code = 0;
+
+my %expected_downloaded_files = (
+    'filename.txt' => {
+        content => $dummyfile,
+        timestamp => 1097310600, # "Sat, 09 Oct 2004 08:30:00 GMT"
+    }
+);
+
+###############################################################################
+
+my $the_test = HTTPTest->new (name => "Test-N-HTTP-Content-Disposition",
+                              input => \%urls, 
+                              cmdline => $cmdline, 
+                              errcode => $expected_error_code, 
+                              output => \%expected_downloaded_files);
+exit $the_test->run();
+
+# vim: et ts=4 sw=4
+
diff --git a/tests/Test-O--no-content-disposition-trivial.px b/tests/Test-O--no-content-disposition-trivial.px
new file mode 100755 (executable)
index 0000000..be25960
--- /dev/null
@@ -0,0 +1,46 @@
+#!/usr/bin/perl -w
+
+use strict;
+
+use HTTPTest;
+
+
+###############################################################################
+
+my $dummyfile = <<EOF;
+Don't care.
+EOF
+
+# code, msg, headers, content
+my %urls = (
+    '/dummy.txt' => {
+        code => "200",
+        msg => "Dontcare",
+        headers => {
+            "Content-type" => "text/plain",
+        },
+        content => $dummyfile
+    },
+);
+
+my $cmdline = $WgetTest::WGETPATH . " -O out --no-content-disposition http://localhost:8080/dummy.txt";
+
+my $expected_error_code = 0;
+
+my %expected_downloaded_files = (
+    'out' => {
+        content => $dummyfile,
+    }
+);
+
+###############################################################################
+
+my $the_test = HTTPTest->new (name => "Test-O--no-content-disposition-trivial",
+                              input => \%urls, 
+                              cmdline => $cmdline, 
+                              errcode => $expected_error_code, 
+                              output => \%expected_downloaded_files);
+exit $the_test->run();
+
+# vim: et ts=4 sw=4
+
diff --git a/tests/Test-O--no-content-disposition.px b/tests/Test-O--no-content-disposition.px
new file mode 100755 (executable)
index 0000000..47cab07
--- /dev/null
@@ -0,0 +1,47 @@
+#!/usr/bin/perl -w
+
+use strict;
+
+use HTTPTest;
+
+
+###############################################################################
+
+my $dummyfile = <<EOF;
+Don't care.
+EOF
+
+# code, msg, headers, content
+my %urls = (
+    '/dummy.txt' => {
+        code => "200",
+        msg => "Dontcare",
+        headers => {
+            "Content-type" => "text/plain",
+            "Content-Disposition" => "attachment; filename=\"filename.txt\"",
+        },
+        content => $dummyfile
+    },
+);
+
+my $cmdline = $WgetTest::WGETPATH . " -O out --no-content-disposition http://localhost:8080/dummy.txt";
+
+my $expected_error_code = 0;
+
+my %expected_downloaded_files = (
+    'out' => {
+        content => $dummyfile,
+    }
+);
+
+###############################################################################
+
+my $the_test = HTTPTest->new (name => "Test-O--no-content-disposition",
+                              input => \%urls, 
+                              cmdline => $cmdline, 
+                              errcode => $expected_error_code, 
+                              output => \%expected_downloaded_files);
+exit $the_test->run();
+
+# vim: et ts=4 sw=4
+
diff --git a/tests/Test-O-HTTP-Content-Disposition.px b/tests/Test-O-HTTP-Content-Disposition.px
new file mode 100755 (executable)
index 0000000..b0a5aa4
--- /dev/null
@@ -0,0 +1,47 @@
+#!/usr/bin/perl -w
+
+use strict;
+
+use HTTPTest;
+
+
+###############################################################################
+
+my $dummyfile = <<EOF;
+Don't care.
+EOF
+
+# code, msg, headers, content
+my %urls = (
+    '/dummy.txt' => {
+        code => "200",
+        msg => "Dontcare",
+        headers => {
+            "Content-type" => "text/plain",
+            "Content-Disposition" => "attachment; filename=\"filename.txt\"",
+        },
+        content => $dummyfile
+    },
+);
+
+my $cmdline = $WgetTest::WGETPATH . " -O out http://localhost:8080/dummy.txt";
+
+my $expected_error_code = 0;
+
+my %expected_downloaded_files = (
+    'out' => {
+        content => $dummyfile,
+    }
+);
+
+###############################################################################
+
+my $the_test = HTTPTest->new (name => "Test-O-HTTP-Content-Disposition",
+                              input => \%urls, 
+                              cmdline => $cmdline, 
+                              errcode => $expected_error_code, 
+                              output => \%expected_downloaded_files);
+exit $the_test->run();
+
+# vim: et ts=4 sw=4
+