Skip to content

Commit

Permalink
gitweb: blobs defined by non-textual hash ids can be cached
Browse files Browse the repository at this point in the history
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
  • Loading branch information
Jakub Narebski authored and Junio C Hamano committed Aug 26, 2006
1 parent 17848fc commit f2e7330
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions gitweb/gitweb.perl
Original file line number Diff line number Diff line change
Expand Up @@ -2363,6 +2363,12 @@ sub git_heads {
}

sub git_blob_plain {
# blobs defined by non-textual hash id's can be cached
my $expires;
if ($hash =~ m/^[0-9a-fA-F]{40}$/) {
$expires = "+1d";
}

if (!defined $hash) {
if (defined $file_name) {
my $base = $hash_base || git_get_head_hash($project);
Expand All @@ -2386,8 +2392,10 @@ sub git_blob_plain {
$save_as .= '.txt';
}

print $cgi->header(-type => "$type",
-content_disposition => "inline; filename=\"$save_as\"");
print $cgi->header(
-type => "$type",
-expires=>$expires,
-content_disposition => "inline; filename=\"$save_as\"");
undef $/;
binmode STDOUT, ':raw';
print <$fd>;
Expand All @@ -2397,6 +2405,12 @@ sub git_blob_plain {
}

sub git_blob {
# blobs defined by non-textual hash id's can be cached
my $expires;
if ($hash =~ m/^[0-9a-fA-F]{40}$/) {
$expires = "+1d";
}

if (!defined $hash) {
if (defined $file_name) {
my $base = $hash_base || git_get_head_hash($project);
Expand All @@ -2414,7 +2428,7 @@ sub git_blob {
close $fd;
return git_blob_plain($mimetype);
}
git_header_html();
git_header_html(undef, $expires);
my $formats_nav = '';
if (defined $hash_base && (my %co = parse_commit($hash_base))) {
if (defined $file_name) {
Expand Down

0 comments on commit f2e7330

Please sign in to comment.