Subject: | HTTP::Cookies doesn't handle expires = Thu Jan 1 00:00:00 1970; correctly |
HTTP::Cookies seems to have an issue when expires is set to 1970-01-01 00:00:00 (ie epoch 0)
or the few hours after it.
The attached script prints a cookie header for a cookie that have explicitly been set to expire.
Subject: | lwp_epoch_cookies.pl |
#!/usr/bin/perl
use strict;
use HTTP::Cookies;
use HTTP::Request;
use HTTP::Response;
my $jar = HTTP::Cookies->new();
my $r = HTTP::Response->new(200, "OK", [
"Set-Cookie" => "test=1; path=/; expires=Sun Feb 24 16:34:08 2036;"
], "");
$r->request(HTTP::Request->new(GET => "http://localhost/"));
$jar->extract_cookies($r);
my $r2 = HTTP::Response->new(200, "OK", [
"Set-Cookie" => "test=1; path=/; expires=Fri Jan 1 00:00:00 1970;"
], "");
$r2->request(HTTP::Request->new(GET => "http://localhost/"));
$jar->extract_cookies($r2);
my $req = HTTP::Request->new(GET => "http://localhost/");
$jar->add_cookie_header($req);
print $req->as_string;