about summary refs log tree commit homepage
path: root/lib/PublicInbox/GitHTTPBackend.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2019-12-25 07:50:47 +0000
committerEric Wong <e@80x24.org>2019-12-26 10:48:19 +0000
commita7949988f7f8690c868d2150fe3000fcf6a6d5f4 (patch)
tree71c6782191d29573c4e2b025eb4b6d81deddd7ff /lib/PublicInbox/GitHTTPBackend.pm
parent3eba4cbd05b348622e772889b06a5994ba69d157 (diff)
downloadpublic-inbox-a7949988f7f8690c868d2150fe3000fcf6a6d5f4.tar.gz
Callers can supply an arg to parse_hdr, now, eliminating the
need for closures to capture local variables.
Diffstat (limited to 'lib/PublicInbox/GitHTTPBackend.pm')
-rw-r--r--lib/PublicInbox/GitHTTPBackend.pm12
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/PublicInbox/GitHTTPBackend.pm b/lib/PublicInbox/GitHTTPBackend.pm
index ec8e6516..537a1947 100644
--- a/lib/PublicInbox/GitHTTPBackend.pm
+++ b/lib/PublicInbox/GitHTTPBackend.pm
@@ -184,6 +184,12 @@ sub prepare_range {
         ($code, $len);
 }
 
+sub git_parse_hdr { # {parse_hdr} for Qspawn
+        my ($r, $bref, $dumb_args) = @_;
+        my $res = parse_cgi_headers($r, $bref) or return; # incomplete
+        $res->[0] == 403 ? serve_dumb(@$dumb_args) : $res;
+}
+
 # returns undef if 403 so it falls back to dumb HTTP
 sub serve_smart {
         my ($env, $git, $path) = @_;
@@ -204,11 +210,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 { # parse_hdr
-                my ($r, $bref) = @_;
-                my $res = parse_cgi_headers($r, $bref) or return; # incomplete
-                $res->[0] == 403 ? serve_dumb($env, $git, $path) : $res;
-        });
+        $qsp->psgi_return($env, $limiter, \&git_parse_hdr, [$env, $git, $path]);
 }
 
 sub input_prepare {