]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/GitHTTPBackend.pm
config: support "inboxdir" in addition to "mainrepo"
[public-inbox.git] / lib / PublicInbox / GitHTTPBackend.pm
index 303d5073850960943685719e6d49e297744979cb..ec8e651699f4d3e521489483e7d337055fd0b75e 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (C) 2016-2018 all contributors <meta@public-inbox.org>
+# Copyright (C) 2016-2019 all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 
 # when no endpoints match, fallback to this and serve a static file
@@ -12,6 +12,7 @@ use HTTP::Date qw(time2str);
 use HTTP::Status qw(status_message);
 use Plack::Util;
 use PublicInbox::Qspawn;
+use PublicInbox::Tmpfile;
 
 # 32 is same as the git-daemon connection limit
 my $default_limiter = PublicInbox::Qspawn::Limiter->new(32);
@@ -203,7 +204,7 @@ sub serve_smart {
        $env{PATH_TRANSLATED} = "$git->{git_dir}/$path";
        my $rdr = input_prepare($env) or return r(500);
        my $qsp = PublicInbox::Qspawn->new([qw(git http-backend)], \%env, $rdr);
-       $qsp->psgi_return($env, $limiter, sub {
+       $qsp->psgi_return($env, $limiter, sub { # parse_hdr
                my ($r, $bref) = @_;
                my $res = parse_cgi_headers($r, $bref) or return; # incomplete
                $res->[0] == 403 ? serve_dumb($env, $git, $path) : $res;
@@ -218,7 +219,8 @@ sub input_prepare {
        if (defined $fd && $fd >= 0) {
                return { 0 => $fd };
        }
-       open(my $in, '+>', undef);
+       my $id = "git-http.input.$env->{REMOTE_ADDR}:$env->{REMOTE_PORT}";
+       my $in = tmpfile($id);
        unless (defined $in) {
                err($env, "could not open temporary file: $!");
                return;