2010-06-04 05:12:19 -04:00
|
|
|
#!/usr/bin/env perl
|
2009-08-27 03:40:48 -04:00
|
|
|
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
|
|
|
|
use HTTPTest;
|
|
|
|
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
|
|
|
|
my $page1 = "Hello, world!\n";
|
|
|
|
my $page2 = "Goodbye, Sam.\n";
|
2012-11-09 09:50:03 -05:00
|
|
|
my $page3 = "Page three.\n";
|
|
|
|
my $page4 = "Page four.\n";
|
|
|
|
my $page5 = "Page five.\n";
|
|
|
|
my $page6 = "Page six.\n";
|
2009-08-27 03:40:48 -04:00
|
|
|
|
|
|
|
# code, msg, headers, content
|
|
|
|
my %urls = (
|
|
|
|
'/one.txt' => {
|
|
|
|
code => "200",
|
|
|
|
msg => "Ok",
|
|
|
|
headers => {
|
|
|
|
"Content-type" => "text/plain",
|
|
|
|
"Set-Cookie" => "foo=bar",
|
|
|
|
},
|
|
|
|
content => $page1,
|
|
|
|
},
|
|
|
|
'/two.txt' => {
|
|
|
|
code => "200",
|
|
|
|
msg => "Ok",
|
|
|
|
content => $page2,
|
|
|
|
request_headers => {
|
|
|
|
"Cookie" => qr|foo=bar|,
|
|
|
|
},
|
|
|
|
},
|
2012-11-09 09:50:03 -05:00
|
|
|
# remove the cookie 'foo'
|
|
|
|
'/three.txt' => {
|
|
|
|
code => "200",
|
|
|
|
msg => "Ok",
|
|
|
|
headers => {
|
|
|
|
"Content-type" => "text/plain",
|
|
|
|
"Set-Cookie" => "foo=; Expires=Sun, 06 Nov 1994 08:49:37 GMT",
|
|
|
|
},
|
|
|
|
content => $page3,
|
|
|
|
},
|
|
|
|
'/four.txt' => {
|
|
|
|
code => "200",
|
|
|
|
msg => "Ok",
|
|
|
|
content => $page4,
|
|
|
|
request_headers => {
|
|
|
|
"!Cookie" => qr|foo=|,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
# try to set a cookie 'foo' with mismatching domain
|
|
|
|
# see RFC 6265 5.3.6: ignore the cookie if it doesn't domain-match
|
|
|
|
'/five.txt' => {
|
|
|
|
code => "200",
|
|
|
|
msg => "Ok",
|
|
|
|
headers => {
|
|
|
|
"Content-type" => "text/plain",
|
|
|
|
"Set-Cookie" => "foo=bar; domain=.example.com",
|
|
|
|
},
|
|
|
|
content => $page5,
|
|
|
|
},
|
|
|
|
'/six.txt' => {
|
|
|
|
code => "200",
|
|
|
|
msg => "Ok",
|
|
|
|
content => $page6,
|
|
|
|
request_headers => {
|
|
|
|
"!Cookie" => qr|foo=bar|,
|
|
|
|
},
|
|
|
|
},
|
2009-08-27 03:40:48 -04:00
|
|
|
);
|
|
|
|
|
|
|
|
my $cmdline = $WgetTest::WGETPATH . " http://localhost:{{port}}/one.txt"
|
2012-11-09 09:50:03 -05:00
|
|
|
. " http://localhost:{{port}}/two.txt" . " http://localhost:{{port}}/three.txt"
|
|
|
|
. " http://localhost:{{port}}/four.txt" . " http://localhost:{{port}}/five.txt"
|
|
|
|
. " http://localhost:{{port}}/six.txt";
|
2009-08-27 03:40:48 -04:00
|
|
|
|
|
|
|
my $expected_error_code = 0;
|
|
|
|
|
|
|
|
my %expected_downloaded_files = (
|
|
|
|
'one.txt' => {
|
|
|
|
content => $page1,
|
|
|
|
},
|
|
|
|
'two.txt' => {
|
|
|
|
content => $page2,
|
|
|
|
},
|
2012-11-09 09:50:03 -05:00
|
|
|
'three.txt' => {
|
|
|
|
content => $page3,
|
|
|
|
},
|
|
|
|
'four.txt' => {
|
|
|
|
content => $page4,
|
|
|
|
},
|
|
|
|
'five.txt' => {
|
|
|
|
content => $page5,
|
|
|
|
},
|
|
|
|
'six.txt' => {
|
|
|
|
content => $page6,
|
|
|
|
},
|
2009-08-27 03:40:48 -04:00
|
|
|
);
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
|
|
|
|
my $the_test = HTTPTest->new (name => "Test-cookies",
|
2009-09-21 23:39:44 -04:00
|
|
|
input => \%urls,
|
|
|
|
cmdline => $cmdline,
|
|
|
|
errcode => $expected_error_code,
|
2009-08-27 03:40:48 -04:00
|
|
|
output => \%expected_downloaded_files);
|
|
|
|
exit $the_test->run();
|
|
|
|
|
|
|
|
# vim: et ts=4 sw=4
|