]> Sergey Matveev's repositories - public-inbox.git/commitdiff
www: cgit: fix fallback to WwwCoderepo on array responses
authorEric Wong <e@80x24.org>
Sat, 8 Oct 2022 08:24:47 +0000 (08:24 +0000)
committerEric Wong <e@80x24.org>
Sun, 9 Oct 2022 16:48:38 +0000 (16:48 +0000)
For fast PSGI responses which don't require returning a coderef,
just reuse qspawn.wcb directly on the arrayref to avoid an undef
$wcb from firing in psgi_return_init_cb.

I only noticed this because the ViewVCS search form is broken
for /$CODEREPO/$OID/s/ endpoints at the moment.

lib/PublicInbox/GitHTTPBackend.pm

index 61a1356048bfc735ed96cf9714f8257378042ff3..3aae54548dc990fef9e93e0e751a7fc7e782664a 100644 (file)
@@ -155,7 +155,11 @@ sub parse_cgi_headers {
                delete $ctx->{env}->{'qspawn.wcb'};
                $ctx->{env}->{'plack.skip-deflater'} = 1; # prevent 2x gzip
                my $res = $ctx->{www}->coderepo->srv(\%ctx);
-               $res->(delete $ctx{env}->{'qspawn.wcb'}) if ref($res) eq 'CODE';
+               if (ref($res) eq 'CODE') {
+                       $res->(delete $ctx{env}->{'qspawn.wcb'});
+               } else { # ref($res) eq 'ARRAY'
+                       $ctx->{env}->{'qspawn.wcb'} = $ctx{env}->{'qspawn.wcb'};
+               }
                $res; # non ARRAY ref for ->psgi_return_init_cb
        } else {
                [ $code, \@h ]