+2009-09-07 Micah Cowan <micah@cowan.name>
+
+ * FTPServer.pm (FTPServer::run): Pass "server behavior" information to
+ newly-constructed FTPPaths object.
+ (FTPPaths::initialize): Accept "server behavior" hash.
+ (FTPPaths::_format_for_list): If server behavior has "bad_list"
+ set, then always report 0 for the size.
+ * Test-ftp-bad-list.px: Added. Attempts to reproduce bug
+ 22403... but doesn't.
+ * run-px, Makefile.am (EXTRA_DIST): Added Test-ftp-bad-list.px.
+
2009-09-06 Micah Cowan <micah@cowan.name>
* WgetTest.pm.in (_setup): Don't expect error codes from
print STDERR "in child\n" if $log;
my $conn = {
- 'paths' => FTPPaths->new($self->{'_input'}),
+ 'paths' => FTPPaths->new($self->{'_input'},
+ $self->{'_server_behavior'}),
'socket' => $socket,
'state' => $_connection_states{NEWCONN},
'dir' => '/',
}
sub initialize {
- my ($self, $urls) = @_;
+ my ($self, $urls, $behavior) = @_;
my $paths = {_type => 'd'};
# From a path like '/foo/bar/baz.txt', construct $paths such that
}
$self->{'_paths'} = $paths;
+ $self->{'_behavior'} = $behavior;
}
sub get_info {
my $size = 0;
if ($info->{'_type'} eq 'f') {
$size = length $info->{'content'};
+ if ($self->{'_behavior'}{'bad_list'}) {
+ $size = 0;
+ }
}
my $date = strftime ("%b %e %H:%M", localtime);
return "$mode_str 1 0 0 $size $date $name";
Test-E-k.px \
Test-ftp.px \
Test-ftp-pasv-fail.px \
+ Test-ftp-bad-list.px \
Test-ftp-recursive.px \
Test-ftp-iri.px \
Test-ftp-iri-fallback.px \
--- /dev/null
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use FTPTest;
+
+
+###############################################################################
+
+my $afile = <<EOF;
+Some text.
+EOF
+
+my $bfile = <<EOF;
+Some more text.
+EOF
+
+$afile =~ s/\n/\r\n/g;
+$bfile =~ s/\n/\r\n/g;
+
+# code, msg, headers, content
+my %urls = (
+ '/afile.txt' => {
+ content => $afile,
+ },
+ '/bfile.txt' => {
+ content => $bfile,
+ },
+);
+
+my $cmdline = $WgetTest::WGETPATH . " -d -nH -Nc -r ftp://localhost:{{port}}/";
+
+my $expected_error_code = 0;
+
+# Don't need to worry about timestamps, the "bad_list" setting will
+# ensure the sizes don't match expectations, and so they'll always be
+# re-downloaded.
+my %expected_downloaded_files = (
+ 'afile.txt' => {
+ content => $afile,
+ },
+ 'bfile.txt' => {
+ content => $bfile,
+ },
+);
+
+my %preexisting_files = (
+ 'afile.txt' => {
+ content => $afile,
+ },
+ 'bfile.txt' => {
+ content => $bfile,
+ },
+);
+
+###############################################################################
+
+my $the_test = FTPTest->new (name => "Test-ftp-bad-list",
+ input => \%urls,
+ cmdline => $cmdline,
+ errcode => $expected_error_code,
+ output => \%expected_downloaded_files,
+ existing => \%preexisting_files,
+ server_behavior => {bad_list => 1});
+exit $the_test->run();
+
+# vim: et ts=4 sw=4
+
'Test-E-k.px',
'Test-ftp.px',
'Test-ftp-pasv-fail.px',
+ 'Test-ftp-bad-list.px',
'Test-ftp-recursive.px',
'Test-ftp-iri.px',
'Test-ftp-iri-fallback.px',