From 6e3d978b8bca9b9b3408590e9733d5c93cf90f6d Mon Sep 17 00:00:00 2001 From: micah Date: Wed, 29 Aug 2007 21:16:24 -0700 Subject: [PATCH] [svn] Fix #20323 - Adjustments and tests for when HEAD should be sent. --- src/ChangeLog | 26 +++++ src/http.c | 45 +++++-- tests/ChangeLog | 52 +++++++-- tests/Makefile.in | 15 +++ tests/Test--no-content-disposition-trivial.px | 55 +++++++++ tests/Test--no-content-disposition.px | 56 +++++++++ ...-spider--no-content-disposition-trivial.px | 52 +++++++++ tests/Test--spider--no-content-disposition.px | 53 +++++++++ .../Test--spider-HTTP-Content-Disposition.px | 53 +++++++++ ...pider-r--no-content-disposition-trivial.px | 109 +++++++++++++++++ .../Test--spider-r--no-content-disposition.px | 110 ++++++++++++++++++ ...Test--spider-r-HTTP-Content-Disposition.px | 110 ++++++++++++++++++ .../Test-N--no-content-disposition-trivial.px | 48 ++++++++ tests/Test-N--no-content-disposition.px | 49 ++++++++ tests/Test-N-HTTP-Content-Disposition.px | 49 ++++++++ .../Test-O--no-content-disposition-trivial.px | 46 ++++++++ tests/Test-O--no-content-disposition.px | 47 ++++++++ tests/Test-O-HTTP-Content-Disposition.px | 47 ++++++++ 18 files changed, 1003 insertions(+), 19 deletions(-) create mode 100755 tests/Test--no-content-disposition-trivial.px create mode 100755 tests/Test--no-content-disposition.px create mode 100755 tests/Test--spider--no-content-disposition-trivial.px create mode 100755 tests/Test--spider--no-content-disposition.px create mode 100755 tests/Test--spider-HTTP-Content-Disposition.px create mode 100755 tests/Test--spider-r--no-content-disposition-trivial.px create mode 100755 tests/Test--spider-r--no-content-disposition.px create mode 100755 tests/Test--spider-r-HTTP-Content-Disposition.px create mode 100755 tests/Test-N--no-content-disposition-trivial.px create mode 100755 tests/Test-N--no-content-disposition.px create mode 100755 tests/Test-N-HTTP-Content-Disposition.px create mode 100755 tests/Test-O--no-content-disposition-trivial.px create mode 100755 tests/Test-O--no-content-disposition.px create mode 100755 tests/Test-O-HTTP-Content-Disposition.px diff --git a/src/ChangeLog b/src/ChangeLog index be8233ef..d8f2fa97 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -33,6 +33,21 @@ * spider.c (in_url_list_p): Removed the bool verbose argument +2007-08-22 Mauro Tortonesi + + * http.c (http_loop): Fall back to GET if HEAD fails with a 500 or 501 + error code. + +2007-08-21 Mauro Tortonesi + + * http.c (http_loop): Send preliminary HEAD request if -N is given and + the destination file exists already. + +2007-08-10 Mauro Tortonesi + + * http.c (http_loop): Fixed HTTP HEAD requests logic when --spider is + given. + 2007-08-10 Ralf Wildenhues * url.c (append_uri_pathel): Do not assume dest string to be @@ -110,6 +125,12 @@ * test.h: tests made more verbose; now displays the name of each test run. +2007-07-10 Mauro Tortonesi + + * 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 * cmpt.c, connect.c, connect.h, convert.c, convert.h: @@ -127,6 +148,11 @@ Updated GPL reference to version 3 or later, removed FSF address. +2007-07-04 Mauro Tortonesi + + * http.c (http_loop): Skip HEAD request and start immediately with GET + if -O is given. + 2007-02-02 Hrvoje Niksic * http.c (print_server_response): Escape non-printable characters diff --git a/src/http.c b/src/http.c index 414e8e69..0dec2235 100644 --- a/src/http.c +++ b/src/http.c @@ -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; + bool send_head_first = true; /* 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; + /* 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 { @@ -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. */ - 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; @@ -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); - + 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 (); } - + 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); } + + /* 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. */ - if (opt.spider) + else if (opt.spider) { /* #### Again: ugly ugly ugly! */ if (!hurl) @@ -2518,7 +2539,7 @@ Remote file does not exist -- broken link!!!\n")); } /* Did we get the time-stamp? */ - if (!got_head) + if (send_head_first && !got_head) { bool restart_loop = false; @@ -2584,12 +2605,6 @@ The sizes do not match (local %s) -- retrieving.\n"), restart_loop = true; } - if (opt.always_rest) - { - got_name = true; - restart_loop = true; - } - 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 */ diff --git a/tests/ChangeLog b/tests/ChangeLog index c5b42778..b80fa17d 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,17 +1,34 @@ 2007-08-21 Mauro Tortonesi - * 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. - * 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 + + * 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 @@ -29,6 +46,27 @@ ensure that correct basic creds are sent, but never until a challenge has been sent. +2007-07-10 Mauro Tortonesi + + * 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 * Makefile.in: diff --git a/tests/Makefile.in b/tests/Makefile.in index 21d76410..7e7eff7a 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -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-N-current-HTTP-CD.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-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--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-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 diff --git a/tests/Test--no-content-disposition-trivial.px b/tests/Test--no-content-disposition-trivial.px new file mode 100755 index 00000000..1d64125a --- /dev/null +++ b/tests/Test--no-content-disposition-trivial.px @@ -0,0 +1,55 @@ +#!/usr/bin/perl -w + +use strict; + +use HTTPTest; + + +############################################################################### + +my $dummyfile = < + + Page Title + + +

+ Some text. +

+ + +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 index 00000000..d5433f00 --- /dev/null +++ b/tests/Test--no-content-disposition.px @@ -0,0 +1,56 @@ +#!/usr/bin/perl -w + +use strict; + +use HTTPTest; + + +############################################################################### + +my $dummyfile = < + + Page Title + + +

+ Some text. +

+ + +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 index 00000000..323db074 --- /dev/null +++ b/tests/Test--spider--no-content-disposition-trivial.px @@ -0,0 +1,52 @@ +#!/usr/bin/perl -w + +use strict; + +use HTTPTest; + + +############################################################################### + +my $mainpage = < + + Main Page + + +

+ Some text. +

+ + +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 index 00000000..acf73a79 --- /dev/null +++ b/tests/Test--spider--no-content-disposition.px @@ -0,0 +1,53 @@ +#!/usr/bin/perl -w + +use strict; + +use HTTPTest; + + +############################################################################### + +my $mainpage = < + + Main Page + + +

+ Some text. +

+ + +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 index 00000000..79eaba5a --- /dev/null +++ b/tests/Test--spider-HTTP-Content-Disposition.px @@ -0,0 +1,53 @@ +#!/usr/bin/perl -w + +use strict; + +use HTTPTest; + + +############################################################################### + +my $mainpage = < + + Main Page + + +

+ Some text. +

+ + +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 index 00000000..0e290c28 --- /dev/null +++ b/tests/Test--spider-r--no-content-disposition-trivial.px @@ -0,0 +1,109 @@ +#!/usr/bin/perl -w + +use strict; + +use HTTPTest; + + +############################################################################### + +my $mainpage = < + + Main Page + + +

+ Some text and a link to a second page. + Also, a broken link. +

+ + +EOF + +my $secondpage = < + + Second Page + + +

+ Some text and a link to a third page. + Also, a broken link. +

+ + +EOF + +my $thirdpage = < + + Third Page + + +

+ Some text and a link to a text file. + Also, another broken link. +

+ + +EOF + +my $dummyfile = < { + 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 index 00000000..0e3c00ed --- /dev/null +++ b/tests/Test--spider-r--no-content-disposition.px @@ -0,0 +1,110 @@ +#!/usr/bin/perl -w + +use strict; + +use HTTPTest; + + +############################################################################### + +my $mainpage = < + + Main Page + + +

+ Some text and a link to a second page. + Also, a broken link. +

+ + +EOF + +my $secondpage = < + + Second Page + + +

+ Some text and a link to a third page. + Also, a broken link. +

+ + +EOF + +my $thirdpage = < + + Third Page + + +

+ Some text and a link to a text file. + Also, another broken link. +

+ + +EOF + +my $dummyfile = < { + 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 index 00000000..e70f6b40 --- /dev/null +++ b/tests/Test--spider-r-HTTP-Content-Disposition.px @@ -0,0 +1,110 @@ +#!/usr/bin/perl -w + +use strict; + +use HTTPTest; + + +############################################################################### + +my $mainpage = < + + Main Page + + +

+ Some text and a link to a second page. + Also, a broken link. +

+ + +EOF + +my $secondpage = < + + Second Page + + +

+ Some text and a link to a third page. + Also, a broken link. +

+ + +EOF + +my $thirdpage = < + + Third Page + + +

+ Some text and a link to a text file. + Also, another broken link. +

+ + +EOF + +my $dummyfile = < { + 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 index 00000000..390d369b --- /dev/null +++ b/tests/Test-N--no-content-disposition-trivial.px @@ -0,0 +1,48 @@ +#!/usr/bin/perl -w + +use strict; + +use HTTPTest; + + +############################################################################### + +my $dummyfile = < { + 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 index 00000000..dbec7c67 --- /dev/null +++ b/tests/Test-N--no-content-disposition.px @@ -0,0 +1,49 @@ +#!/usr/bin/perl -w + +use strict; + +use HTTPTest; + + +############################################################################### + +my $dummyfile = < { + 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 index 00000000..8c5e4181 --- /dev/null +++ b/tests/Test-N-HTTP-Content-Disposition.px @@ -0,0 +1,49 @@ +#!/usr/bin/perl -w + +use strict; + +use HTTPTest; + + +############################################################################### + +my $dummyfile = < { + 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 index 00000000..be25960c --- /dev/null +++ b/tests/Test-O--no-content-disposition-trivial.px @@ -0,0 +1,46 @@ +#!/usr/bin/perl -w + +use strict; + +use HTTPTest; + + +############################################################################### + +my $dummyfile = < { + 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 index 00000000..47cab071 --- /dev/null +++ b/tests/Test-O--no-content-disposition.px @@ -0,0 +1,47 @@ +#!/usr/bin/perl -w + +use strict; + +use HTTPTest; + + +############################################################################### + +my $dummyfile = < { + 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 index 00000000..b0a5aa40 --- /dev/null +++ b/tests/Test-O-HTTP-Content-Disposition.px @@ -0,0 +1,47 @@ +#!/usr/bin/perl -w + +use strict; + +use HTTPTest; + + +############################################################################### + +my $dummyfile = < { + 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 +