Skip to content

Commit b33998b

Browse files
Lxgenio
authored andcommitted
Add TODO tests for save() ignore_discard argument
1 parent 1c805bc commit b33998b

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

t/cookies.t

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!perl -w
22

33
use Test;
4-
plan tests => 77;
4+
plan tests => 79, todo => [78, 79];
55

66
use HTTP::Cookies;
77
use HTTP::Request;
@@ -698,6 +698,38 @@ ok(@a, 2);
698698
ok($a[0], undef);
699699
ok($a[1], 42);
700700

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+
701733

702734
#-------------------------------------------------------------------
703735

0 commit comments

Comments
 (0)