| 1 |
#!/usr/bin/env perl |
| 2 |
|
| 3 |
use strict; |
| 4 |
use warnings; |
| 5 |
|
| 6 |
use HTTPTest; |
| 7 |
|
| 8 |
|
| 9 |
############################################################################### |
| 10 |
|
| 11 |
my $partiallydownloaded = <<EOF; |
| 12 |
11111111111111111111111111111111111111111111111111 |
| 13 |
22222222x222222222222222222222222222222222222222222222222222 |
| 14 |
EOF |
| 15 |
|
| 16 |
my $rest = <<EOF; |
| 17 |
3333333333333333333333333333333333333333333333333333333333333333333333 |
| 18 |
444444444444444444444444444444444444444444444444444444444444 |
| 19 |
55555555555555555555555555555555555555555555555555 |
| 20 |
EOF |
| 21 |
|
| 22 |
my $wholefile = <<EOF . $rest; |
| 23 |
11111111111111111111111111111111111111111111111111 |
| 24 |
222222222222222222222222222222222222222222222222222222222222 |
| 25 |
EOF |
| 26 |
|
| 27 |
my $downloadedfile = $partiallydownloaded . $rest; |
| 28 |
|
| 29 |
# code, msg, headers, content |
| 30 |
my %urls = ( |
| 31 |
'/somefile.txt' => { |
| 32 |
code => "200", |
| 33 |
msg => "Dontcare", |
| 34 |
headers => { |
| 35 |
"Content-type" => "text/plain", |
| 36 |
}, |
| 37 |
content => $wholefile, |
| 38 |
}, |
| 39 |
); |
| 40 |
|
| 41 |
my $cmdline = $WgetTest::WGETPATH . " -c http://localhost:{{port}}/somefile.txt"; |
| 42 |
|
| 43 |
my $expected_error_code = 0; |
| 44 |
|
| 45 |
my %existing_files = ( |
| 46 |
'somefile.txt' => { |
| 47 |
content => $partiallydownloaded, |
| 48 |
}, |
| 49 |
); |
| 50 |
|
| 51 |
my %expected_downloaded_files = ( |
| 52 |
'somefile.txt' => { |
| 53 |
content => $downloadedfile, |
| 54 |
}, |
| 55 |
); |
| 56 |
|
| 57 |
############################################################################### |
| 58 |
|
| 59 |
my $the_test = HTTPTest->new (input => \%urls, |
| 60 |
cmdline => $cmdline, |
| 61 |
errcode => $expected_error_code, |
| 62 |
existing => \%existing_files, |
| 63 |
output => \%expected_downloaded_files); |
| 64 |
exit $the_test->run(); |
| 65 |
|
| 66 |
# vim: et ts=4 sw=4 |