+
+ # fallback to WwwCoderepo if cgit 404s. Duplicating $ctx prevents
+ # ->finalize from the current Qspawn from using qspawn.wcb
+ if ($code == 404 && $ctx->{www} && !$ctx->{_coderepo_tried}++) {
+ my %ctx = %$ctx;
+ $ctx{env} = +{ %{$ctx->{env}} };
+ delete $ctx->{env}->{'qspawn.wcb'};
+ $ctx->{env}->{'plack.skip-deflater'} = 1; # prevent 2x gzip
+ my $res = $ctx->{www}->coderepo->srv(\%ctx);
+ 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 ]
+ }