|
1 | 1 | #!perl -w
|
2 | 2 |
|
3 | 3 | use Test;
|
4 |
| -plan tests => 77; |
| 4 | +plan tests => 79, todo => [78, 79]; |
5 | 5 |
|
6 | 6 | use HTTP::Cookies;
|
7 | 7 | use HTTP::Request;
|
@@ -698,6 +698,38 @@ ok(@a, 2);
|
698 | 698 | ok($a[0], undef);
|
699 | 699 | ok($a[1], 42);
|
700 | 700 |
|
| 701 | +# Test ignore_discard argument of save() |
| 702 | +$c = HTTP::Cookies->new( ignore_discard => 0 ); |
| 703 | +interact($c, 'http://example.com/', 'foo=bar; Discard;'); |
| 704 | +$old = $c->as_string; |
| 705 | +$c->save( file => $file, ignore_discard => 1 ); |
| 706 | +undef $c; |
| 707 | + |
| 708 | +$c = HTTP::Cookies->new( ignore_discard => 0 ); |
| 709 | +$c->load($file); |
| 710 | +unlink($file) || warn "Can't unlink $file: $!"; |
| 711 | + |
| 712 | +ok($c->as_string, $old); |
| 713 | + |
| 714 | +$c = HTTP::Cookies::Netscape->new( ignore_discard => 0 ); |
| 715 | +$req = HTTP::Request->new(GET => "http://1.1.1.1/"); |
| 716 | +$req->header("Host", "www.acme.com:80"); |
| 717 | +$res = HTTP::Response->new(200, "OK"); |
| 718 | +$res->request($req); |
| 719 | +$res->header("Set-Cookie" => "foo=bar; path=/; discard; expires=Wednesday, 09-Nov-$year_plus_one 23:12:40 GMT"); |
| 720 | +$c->extract_cookies($res); |
| 721 | +$old = $c->as_string; |
| 722 | +$c->save( file => $file, ignore_discard => 1 ); |
| 723 | +undef $c; |
| 724 | + |
| 725 | +$c = HTTP::Cookies::Netscape->new( ignore_discard => 0 ); |
| 726 | +$c->load($file); |
| 727 | +$req = HTTP::Request->new(GET => "http://www.acme.com/foo/bar"); |
| 728 | +$c->add_cookie_header($req); |
| 729 | +$h = $req->header("Cookie"); |
| 730 | +ok($h =~ /foo=bar/); |
| 731 | +unlink($file) || warn "Can't unlink $file: $!"; |
| 732 | + |
701 | 733 |
|
702 | 734 | #-------------------------------------------------------------------
|
703 | 735 |
|
|
0 commit comments