Skip to content

Commit

Permalink
gitweb: check if-modified-since for feeds
Browse files Browse the repository at this point in the history
Offering Last-modified header for feeds is only half the work, even if
we bail out early on HEAD requests. We should also check that same date
against If-modified-since, and bail out early with 304 Not Modified if
that's the case.

Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Giuseppe Bilotta authored and Junio C Hamano committed Jan 28, 2009
1 parent 2757b54 commit cd956c7
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion gitweb/gitweb.perl
Original file line number Diff line number Diff line change
Expand Up @@ -6015,7 +6015,25 @@ sub git_feed {
}
if (defined($commitlist[0])) {
%latest_commit = %{$commitlist[0]};
%latest_date = parse_date($latest_commit{'committer_epoch'});
my $latest_epoch = $latest_commit{'committer_epoch'};
%latest_date = parse_date($latest_epoch);
my $if_modified = $cgi->http('IF_MODIFIED_SINCE');
if (defined $if_modified) {
my $since;
if (eval { require HTTP::Date; 1; }) {
$since = HTTP::Date::str2time($if_modified);
} elsif (eval { require Time::ParseDate; 1; }) {
$since = Time::ParseDate::parsedate($if_modified, GMT => 1);
}
if (defined $since && $latest_epoch <= $since) {
print $cgi->header(
-type => $content_type,
-charset => 'utf-8',
-last_modified => $latest_date{'rfc2822'},
-status => '304 Not Modified');
return;
}
}
print $cgi->header(
-type => $content_type,
-charset => 'utf-8',
Expand Down

0 comments on commit cd956c7

Please sign in to comment.