]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
psgi_rproxy: fix uploads with small output buffers
authorEric Wong <e@80x24.org>
Thu, 23 Oct 2025 10:21:00 +0000 (10:21 +0000)
committerEric Wong <e@80x24.org>
Fri, 24 Oct 2025 08:15:17 +0000 (08:15 +0000)
Attempting to call pass_res_hdr directly fails when the previous
DS->write to the upstream hit EAGAIN.  Ensure correct ordering
by relying on DS->write to call the pass_res_hdr subroutine
after the previous DS->write is complete.  In other words, we
must not try reading the upstream response until our request is
fully sent to the upstream.

I noticed this after installing HTTP::Parser::XS
(p5-HTTP-Parser-XS) on my FreeBSD machine since our PsgiRproxy
module depends the XS package for parsing HTTP/1.x responses.

lib/PublicInbox/H1ReqRes.pm

index 8f49b45b634bb3c22647b85ad3c1cda6433ee23e..ad99a5c77d9a992212c9f4fb306fffc60828bf30 100644 (file)
@@ -354,7 +354,7 @@ sub send_req_body { # called by flush_write
                $self->requeue if push(@{$self->{wbuf}}, \&send_req_body) == 1;
        } else {
                delete $self->{req_left};
-               pass_res_hdr $self;
+               $self->write(\&pass_res_hdr);
        }
 }