From 03fd65fd5acb38809b66bf2e5af864395e2f6588 Mon Sep 17 00:00:00 2001 From: Frank Lichtenheld Date: Fri, 8 Aug 2008 16:44:55 -0300 Subject: [PATCH] Packages::Dispatcher: Fix date logics again * Due to a inverted test Last-Modified was always set to "now" * Do not allow expires to be in the past --- lib/Packages/Dispatcher.pm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/Packages/Dispatcher.pm b/lib/Packages/Dispatcher.pm index e8f0679..d8b750c 100755 --- a/lib/Packages/Dispatcher.pm +++ b/lib/Packages/Dispatcher.pm @@ -94,9 +94,11 @@ sub do_dispatch { &Packages::DB::init(); my $last_modified = $Packages::DB::db_read_time; my $now = time; + my $expires = $last_modified + (12*3600); + $expires = $now + 3600 if $expires < $now; # allow some fudge, since the db mod time is not the end of # the cron job - $last_modified = $now if $last_modified - $now < 3600; + $last_modified = $now if $now - $last_modified < 3600; if ($input->http('If-Modified-Since') and (my $modtime = str2time($input->http('If-Modified-Since'), 'UTC'))) { @@ -351,7 +353,7 @@ sub do_dispatch { -last_modified => strftime("%a, %d %b %Y %T %z", localtime($last_modified)), -expires => strftime("%a, %d %b %Y %T %z", - localtime($last_modified + (12*3600))), + localtime($expires)), ); #use Data::Dumper; #print '
'.Dumper(\%ENV, \%page_content, get_all_messages()).'
'; -- 2.39.2