X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=lib%2FPublicInbox%2FGitHTTPBackend.pm;h=81ff23fc006d409cb8c5fd2f0d1efa0425fcf0cb;hb=55b707d788ce13696e4411389583e720ea6dab01;hp=8883ec347c18adef02a3abba7d80b7afab530c88;hpb=8de49b2d3097e294650b1ee1554f45c6d2d29d67;p=public-inbox.git diff --git a/lib/PublicInbox/GitHTTPBackend.pm b/lib/PublicInbox/GitHTTPBackend.pm index 8883ec34..81ff23fc 100644 --- a/lib/PublicInbox/GitHTTPBackend.pm +++ b/lib/PublicInbox/GitHTTPBackend.pm @@ -7,12 +7,11 @@ package PublicInbox::GitHTTPBackend; use strict; use warnings; use Fcntl qw(:seek); -use IO::Handle; +use IO::Handle; # ->flush use HTTP::Date qw(time2str); -use HTTP::Status qw(status_message); use PublicInbox::Qspawn; use PublicInbox::Tmpfile; -use PublicInbox::WwwStatic; +use PublicInbox::WwwStatic qw(r @NO_CACHE); # 32 is same as the git-daemon connection limit my $default_limiter = PublicInbox::Qspawn::Limiter->new(32); @@ -32,18 +31,6 @@ our $ANY = join('|', @binary, @text, 'git-upload-pack'); my $BIN = join('|', @binary); my $TEXT = join('|', @text); -my @no_cache = ('Expires', 'Fri, 01 Jan 1980 00:00:00 GMT', - 'Pragma', 'no-cache', - 'Cache-Control', 'no-cache, max-age=0, must-revalidate'); - -sub r ($;$) { - my ($code, $msg) = @_; - $msg ||= status_message($code); - my $len = length($msg); - [ $code, [qw(Content-Type text/plain Content-Length), $len, @no_cache], - [$msg] ] -} - sub serve { my ($env, $git, $path) = @_; @@ -88,12 +75,12 @@ sub serve_dumb { cache_one_year($h); } elsif ($path =~ /\A(?:$TEXT)\z/o) { $type = 'text/plain'; - push @$h, @no_cache; + push @$h, @NO_CACHE; } else { return r(404); } $path = "$git->{git_dir}/$path"; - PublicInbox::WwwStatic::response($env, $h, $path, $type) // r(404); + PublicInbox::WwwStatic::response($env, $h, $path, $type); } sub git_parse_hdr { # {parse_hdr} for Qspawn