fix [ 1489528 ] HTTP header contains invalid time-stamp

This commit is contained in:
JT Smith 2006-05-18 00:09:20 +00:00
parent 6ba68835e0
commit 61050f1aed
3 changed files with 23 additions and 2 deletions

View file

@ -261,6 +261,26 @@ sub DESTROY {
undef $self;
}
#-------------------------------------------------------------------
=head2 epochToHttp ( epcoh )
Converts and epoch date into an HTTP formatted date.
=head3 epoch
An epoch date. Defaults to now.
=cut
sub epochToHttp {
my $self = shift;
my $epoch = shift || time();
my $timeZone = $self->session->user->profileField("timeZone") || "America/Chicago";
my $dt = DateTime->from_epoch( epoch=>$epoch, time_zone=>$timeZone);
$dt->set_time_zone("GMT");
return $dt->strftime("%a, %d %b %Y %H:%m:%S GMT");
}
#-------------------------------------------------------------------

View file

@ -183,7 +183,7 @@ sub sendHeader {
$request->status(301);
} else {
$request->content_type($self->{_http}{mimetype} || "text/html");
my $date = $self->session->datetime->epochToHuman(($self->{_http}{lastModified} || time()), "%W, %d %C %y %j:%m:%s %t");
my $date = $self->session->datetime->epochToHttp($self->{_http}{lastModified});
my $cc = $self->{_http}{cacheControl};
$request->headers_out->set('Last-Modified' => $date);
if ($cc eq "none" || $self->session->setting->get("preventProxyCache") || ($cc eq "" && $self->session->var->get("userId") ne "1")) {
@ -195,7 +195,7 @@ sub sendHeader {
$request->headers_out->set('Cache-Control' => "max-age=" . $cc.$extras);
} elsif ($cc ne "") {
$request->headers_out->set("Cache-Control" => "private") unless ($self->session->var->get("userId") eq "1");
my $date = $self->session->datetime->epochToHuman(time() + $cc, "%W, %d %C %y %j:%m:%s %t");
my $date = $self->session->datetime->epochToHttp(time() + $cc);
$request->headers_out->set('Expires' => $date);
}
if ($self->{_http}{filename}) {