- $r = parse_cgi_headers(\$buf) or return;
- if ($r->[0] == 403) {
- return $q->(serve_dumb($cgi, $git, $path));
+ return $res->($r);
+ }
+ if ($async) {
+ $fh = $res->($r);
+ return $async->async_pass($io, $fh, \$buf);
+ }
+
+ # for synchronous PSGI servers
+ require PublicInbox::GetlineBody;
+ $r->[2] = PublicInbox::GetlineBody->new($rpipe, $end, $buf);
+ $res->($r);
+ };
+ sub {
+ ($res) = @_;
+
+ # hopefully this doesn't break any middlewares,
+ # holding the input here is a waste of FDs and memory
+ $env->{'psgi.input'} = undef;
+
+ $qsp->start($limiter, sub { # may run later, much later...
+ ($rpipe) = @_;
+ $in = undef;
+ if ($async) {
+ $async = $async->($rpipe, $cb, $end);
+ } else { # generic PSGI
+ $cb->() while $rd_hdr;