From: Eric Wong <e@80x24.org>
To: edef <edef@edef.eu>
Cc: meta@public-inbox.org, hi@alyssa.is
Subject: Re: [PATCH 0/1] Fix broken clone URLs due to SCRIPT_NAME getting reset
Date: Thu, 26 Sep 2019 03:03:57 +0000 [thread overview]
Message-ID: <20190926030357.GA21009@dcvr> (raw)
In-Reply-To: <cover.0f97c47bb88db8b875be7497289d8fedd3b11991.1569296942.git-series.edef@edef.eu>
edef <edef@edef.eu> wrote:
> We're trying to get public-inbox working with a PSGI file that mounts
> it to a subdirectory. This seems like it's intended to be a supported
> use case, with stuff paying attention to SCRIPT_NAME and all when
> generating URLs.
>
> However, Plack::App::URLMap seems determined to reset SCRIPT_NAME
> before getline gets called:
>
> my $orig_path_info = $env->{PATH_INFO};
> my $orig_script_name = $env->{SCRIPT_NAME};
>
> $env->{PATH_INFO} = $path;
> $env->{SCRIPT_NAME} = $script_name . $location;
> return $self->response_cb($app->($env), sub {
> $env->{PATH_INFO} = $orig_path_info;
> $env->{SCRIPT_NAME} = $orig_script_name;
> });
Sounds like a familiar problem to me :x
> I'm not sure whether public-inbox or Plack is in the wrong here, but
> the timing works out poorly. By the time
> PublicInbox::WwwStream::_html_end gets invoked SCRIPT_NAME is blank,
> and the wrong URLs get generated.
>
> Copying env seems to fix it, and that's what the attached patch does.
> I'm pretty sure this is the wrong approach, but it seems to work.
Yeah, it's a big hash and not needed to copy the whole thing.
I gotta run, now, but I think the patch below will work for you
by precalculating base_url up front. Can you confirm? Thanks.
Also, I suspect the mbox Archived-At headers could be wrong
and need a similar change... Maybe Atom feeds, too.
diff --git a/lib/PublicInbox/WwwStream.pm b/lib/PublicInbox/WwwStream.pm
index e0823c8d..b240c071 100644
--- a/lib/PublicInbox/WwwStream.pm
+++ b/lib/PublicInbox/WwwStream.pm
@@ -19,7 +19,17 @@ sub close {}
sub new {
my ($class, $ctx, $cb) = @_;
- bless { nr => 0, cb => $cb || *close, ctx => $ctx }, $class;
+
+ my $env = $ctx->{env};
+ my $ibx = $ctx->{-inbox};
+ my $base_url = $ibx->base_url($env);
+ chop $base_url; # no trailing slash for clone
+ bless {
+ nr => 0,
+ cb => $cb || *close,
+ ctx => $ctx,
+ base_url => $base_url,
+ }, $class;
}
sub response {
@@ -83,8 +93,7 @@ sub _html_end {
my $desc = ascii_html($ibx->description);
my (%seen, @urls);
- my $http = $ibx->base_url($ctx->{env});
- chop $http; # no trailing slash for clone
+ my $http = $self->{base_url};
my $max = $ibx->max_git_epoch;
my $dir = (split(m!/!, $http))[-1];
if (defined($max)) { # v2
next prev parent reply other threads:[~2019-09-26 3:03 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-24 4:10 [PATCH 0/1] Fix broken clone URLs due to SCRIPT_NAME getting reset edef
2019-09-24 4:10 ` [PATCH 1/1] wwwstream: copy $ctx->{env} in new edef
2019-09-26 3:03 ` Eric Wong [this message]
2019-10-01 7:13 ` [PATCH] www: fix absolute URLs when mounted under a subdir 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=20190926030357.GA21009@dcvr \
--to=e@80x24.org \
--cc=edef@edef.eu \
--cc=hi@alyssa.is \
--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.
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).