]> sjero.net Git - wget/blob - tests/Test-ftp-pasv-fail.px
Fix build when libpsl is not available
[wget] / tests / Test-ftp-pasv-fail.px
1 #!/usr/bin/env perl
2
3 use strict;
4 use warnings;
5
6 use FTPTest;
7
8 # This file exercises a problem in Wget, where if an error was
9 # encountered in ftp.c:getftp before the actual file download
10 # had started, Wget would believe that it had already downloaded the
11 # full contents of the file, and would send a corresponding (erroneous)
12 # REST value.
13
14 ###############################################################################
15
16 # From bug report. :)
17 my $afile = <<EOF;
18 I've included log output (using the -d switch) from when this happens
19 below. You'll see that for the retry wget sends a REST command to
20 reset the start position before starting the RETR command. I'm
21 confused about the argument to REST: 51132. It's the full length in
22 bytes of the file to be retrieved. The RETR then shows the entire
23 contents of the file being skipped, and wget announces that it
24 successfully retrieved and saved 0 bytes.
25 EOF
26
27 $afile =~ s/\n/\r\n/g;
28
29
30 # code, msg, headers, content
31 my %urls = (
32     '/afile.txt' => {
33         content => $afile,
34     },
35 );
36
37 my $cmdline = $WgetTest::WGETPATH . " -S ftp://localhost:{{port}}/afile.txt";
38
39 my $expected_error_code = 0;
40
41 my %expected_downloaded_files = (
42     'afile.txt' => {
43         content => $afile,
44     },
45 );
46
47 ###############################################################################
48
49 my $the_test = FTPTest->new (name => "Test-ftp-pasv-fail",
50                              server_behavior => {fail_on_pasv => 1},
51                              input => \%urls,
52                              cmdline => $cmdline,
53                              errcode => $expected_error_code,
54                              output => \%expected_downloaded_files);
55 exit $the_test->run();
56
57 # vim: et ts=4 sw=4
58