Skip to content

Commit 34b60ae

Browse files
simbabqueoalders
authored andcommitted
add test for max-age discard
1 parent dacc2b7 commit 34b60ae

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

Changes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ Revision history for HTTP-Cookies. The HTTP::Cookies module used to be bundled
22
with the libwww-perl distribution.
33

44
{{$NEXT}}
5+
- do not set discard if max-age is set (GH#61) (robnagler, simbabque)
56

67
6.09 2020-11-19 22:20:47Z
78
- Allow HttpOnly cookies to be loaded by HTTP::Cookies::Netscape (GH#63)

t/cookies.t

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

33
use Test;
4-
plan tests => 80;
4+
plan tests => 81;
55

66
use HTTP::Cookies;
77
use HTTP::Request;
@@ -605,7 +605,7 @@ $c->add_cookie_header($req);
605605
ok(!$req->header("Cookie"));
606606

607607

608-
# Test cookie called 'exipres' <https://rt.cpan.org/Ticket/Display.html?id=8108>
608+
# Test cookie called 'expires' <https://rt.cpan.org/Ticket/Display.html?id=8108>
609609
$c = HTTP::Cookies->new;
610610
$req = HTTP::Request->new("GET" => "http://example.com");
611611
$res = HTTP::Response->new(200, "OK");
@@ -734,6 +734,19 @@ $h = $req->header("Cookie");
734734
ok($h =~ /foo=bar/);
735735
unlink($file) || warn "Can't unlink $file: $!";
736736

737+
# Test discard isn't set when max-age is set
738+
$c = HTTP::Cookies->new;
739+
$req = HTTP::Request->new("GET" => "http://example.com");
740+
$res = HTTP::Response->new(200, "OK");
741+
$res->request($req);
742+
$res->header("Set-Cookie" => "foo=bar; max-age=1337");
743+
$c->extract_cookies($res);
744+
#print $c->as_string;
745+
ok($c->as_string, <<'EOT');
746+
Set-Cookie3: foo=bar; path="/"; domain=example.com; version=0
747+
EOT
748+
749+
737750

738751
#-------------------------------------------------------------------
739752

0 commit comments

Comments
 (0)