X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=lib%2FPublicInbox%2FGitHTTPBackend.pm;h=81ff23fc006d409cb8c5fd2f0d1efa0425fcf0cb;hb=55b707d788ce13696e4411389583e720ea6dab01;hp=b7640d42a02aecde1c3643e3be7e7177b370df7c;hpb=07d0e2d336d4697c3284fe3dd59dae0583984e23;p=public-inbox.git diff --git a/lib/PublicInbox/GitHTTPBackend.pm b/lib/PublicInbox/GitHTTPBackend.pm index b7640d42..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,24 +31,9 @@ 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) = @_; - # XXX compatibility... ugh, can we stop supporting this? - $git = PublicInbox::Git->new($git) unless ref($git); - # Documentation/technical/http-protocol.txt in git.git # requires one and exactly one query parameter: if ($env->{QUERY_STRING} =~ /\Aservice=git-[A-Za-z0-9_]+-pack\z/ || @@ -91,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 @@ -164,7 +148,7 @@ sub input_prepare { err($env, "error seeking temporary file: $!"); return; } - { 0 => fileno($in), -hold => $in }; + { 0 => $in }; } sub parse_cgi_headers {