Skip to content
Browse files

issue 301; support for max-age in cookies

  • Loading branch information...
1 parent 4f68dc4 commit 84f6225fb58176d0b2f5c0cd637edb08ef17b6e9 @remorse remorse committed Jun 29, 2012
Showing with 7 additions and 4 deletions.
  1. +1 −0 lib/Plack/Response.pm
  2. +6 −4 t/Plack-Response/cookie.t
View
1 lib/Plack/Response.pm
@@ -138,6 +138,7 @@ sub _bake_cookie {
push @cookie, "domain=" . $val->{domain} if $val->{domain};
push @cookie, "path=" . $val->{path} if $val->{path};
push @cookie, "expires=" . $self->_date($val->{expires}) if $val->{expires};
+ push @cookie, "max-age=" . $val->{"max-age"} if $val->{"max-age"};
push @cookie, "secure" if $val->{secure};
push @cookie, "HttpOnly" if $val->{httponly};
View
10 t/Plack-Response/cookie.t
@@ -7,8 +7,9 @@ use HTTP::Request::Common;
my $app = sub {
my $res = Plack::Response->new(200);
- $res->cookies->{foo} = { value => "bar", domain => '.example.com', path => '/cgi-bin' };
- $res->cookies->{bar} = { value => "xxx yyy", expires => time + 3600 };
+ $res->cookies->{t1} = { value => "bar", domain => '.example.com', path => '/cgi-bin' };
+ $res->cookies->{t2} = { value => "xxx yyy", expires => time + 3600 };
+ $res->cookies->{t3} = { value => "123123", "max-age" => 15 };
$res->finalize;
};
@@ -17,8 +18,9 @@ test_psgi $app, sub {
my $res = $cb->(GET "/");
my @v = sort $res->header('Set-Cookie');
- like $v[0], qr/bar=xxx%20yyy; expires=\w+, \d+-\w+-\d+ \d\d:\d\d:\d\d GMT/;
- is $v[1], "foo=bar; domain=.example.com; path=/cgi-bin";
+ is $v[0], "t1=bar; domain=.example.com; path=/cgi-bin";
+ like $v[1], qr/t2=xxx%20yyy; expires=\w+, \d+-\w+-\d+ \d\d:\d\d:\d\d GMT/;
+ is $v[2], "t3=123123; max-age=15";
};
done_testing;

0 comments on commit 84f6225

Please sign in to comment.
Something went wrong with that request. Please try again.