diff --git a/docs/changelog/6.x.x.txt b/docs/changelog/6.x.x.txt index 4af1abe91..df5e7ab77 100644 --- a/docs/changelog/6.x.x.txt +++ b/docs/changelog/6.x.x.txt @@ -29,6 +29,7 @@ - The CS main listing is now 863% faster. - Fixed a problem where last reply column wasn't being updated in the thread. - fix [ 1488556 ] blank page after setup + - fix [ 1489528 ] HTTP header contains invalid time-stamp 6.99.0 diff --git a/lib/WebGUI/Session/DateTime.pm b/lib/WebGUI/Session/DateTime.pm index 90115a2c0..e06c6b118 100644 --- a/lib/WebGUI/Session/DateTime.pm +++ b/lib/WebGUI/Session/DateTime.pm @@ -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"); +} #------------------------------------------------------------------- diff --git a/lib/WebGUI/Session/Http.pm b/lib/WebGUI/Session/Http.pm index e51ebd0f4..02539b431 100644 --- a/lib/WebGUI/Session/Http.pm +++ b/lib/WebGUI/Session/Http.pm @@ -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}) {