From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 1/4] qspawn: use fallback response code from CGI program
Date: Fri, 6 Jan 2023 10:10:50 +0000 [thread overview]
Message-ID: <20230106101053.1461700-2-e@80x24.org> (raw)
In-Reply-To: <20230106101053.1461700-1-e@80x24.org>
Prefer to use the original (cgit||git-http-backend) HTTP
response code if our fallback to WwwCoderepo fails. 404
codes is typically more appropriate than 500 for these things.
---
lib/PublicInbox/GitHTTPBackend.pm | 1 +
lib/PublicInbox/Qspawn.pm | 3 ++-
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/lib/PublicInbox/GitHTTPBackend.pm b/lib/PublicInbox/GitHTTPBackend.pm
index 5b879871..74432429 100644
--- a/lib/PublicInbox/GitHTTPBackend.pm
+++ b/lib/PublicInbox/GitHTTPBackend.pm
@@ -151,6 +151,7 @@ sub parse_cgi_headers { # {parse_hdr} for Qspawn
if ($code == 404 && $ctx->{www} && !$ctx->{_coderepo_tried}++) {
my $wcb = delete $ctx->{env}->{'qspawn.wcb'};
$ctx->{env}->{'plack.skip-deflater'} = 1; # prevent 2x gzip
+ $ctx->{env}->{'qspawn.fallback'} = $code;
my $res = $ctx->{www}->coderepo->srv($ctx);
# for ->psgi_return_init_cb
$ctx->{env}->{'qspawn.wcb'} = $wcb;
diff --git a/lib/PublicInbox/Qspawn.pm b/lib/PublicInbox/Qspawn.pm
index ab0ef25c..f8cbffcb 100644
--- a/lib/PublicInbox/Qspawn.pm
+++ b/lib/PublicInbox/Qspawn.pm
@@ -109,8 +109,9 @@ sub finalize ($$) {
return if $self->{passed}; # another command chained it
if (my $wcb = delete $env->{'qspawn.wcb'}) {
# have we started writing, yet?
+ my $code = delete $env->{'qspawn.fallback'} // 500;
require PublicInbox::WwwStatic;
- $wcb->(PublicInbox::WwwStatic::r(500));
+ $wcb->(PublicInbox::WwwStatic::r($code));
}
}
next prev parent reply other threads:[~2023-01-06 10:11 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-06 10:10 [PATCH 0/4] www_coderepo vs cgit fallback fixes Eric Wong
2023-01-06 10:10 ` Eric Wong [this message]
2023-01-06 10:10 ` [PATCH 2/4] httpd/async: retry reads properly when parsing headers Eric Wong
2023-01-06 10:10 ` [PATCH 3/4] qspawn: consistently return 500 on premature EOF Eric Wong
2023-01-06 10:10 ` [PATCH 4/4] qspawn: fix EINTR with generic PSGI servers Eric Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://public-inbox.org/README
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230106101053.1461700-2-e@80x24.org \
--to=e@80x24.org \
--cc=meta@public-inbox.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/public-inbox.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).