]> sjero.net Git - wget/blob - tests/Test-cookies.px
Heed cookies from 401s.
[wget] / tests / Test-cookies.px
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 use HTTPTest;
7
8
9 ###############################################################################
10
11 my $page1 = "Hello, world!\n";
12 my $page2 = "Goodbye, Sam.\n";
13
14 # code, msg, headers, content
15 my %urls = (
16     '/one.txt' => {
17         code => "200",
18         msg => "Ok",
19         headers => {
20             "Content-type" => "text/plain",
21             "Set-Cookie" => "foo=bar",
22         },
23         content => $page1,
24     },
25     '/two.txt' => {
26         code => "200",
27         msg => "Ok",
28         content => $page2,
29         request_headers => {
30             "Cookie" => qr|foo=bar|,
31         },
32     },
33 );
34
35 my $cmdline = $WgetTest::WGETPATH . " http://localhost:{{port}}/one.txt"
36     . " http://localhost:{{port}}/two.txt";
37
38 my $expected_error_code = 0;
39
40 my %expected_downloaded_files = (
41     'one.txt' => {
42         content => $page1,
43     },
44     'two.txt' => {
45         content => $page2,
46     },
47 );
48
49 ###############################################################################
50
51 my $the_test = HTTPTest->new (name => "Test-cookies",
52                               input => \%urls, 
53                               cmdline => $cmdline, 
54                               errcode => $expected_error_code, 
55                               output => \%expected_downloaded_files);
56 exit $the_test->run();
57
58 # vim: et ts=4 sw=4
59