X-Git-Url: http://www.git.stargrave.org/?p=public-inbox.git;a=blobdiff_plain;f=lib%2FPublicInbox%2FInbox.pm;h=96c92652a54a4e04a64f1fdee65c730ee5ea90de;hp=ada713c741657ef16522d4b118cffebcbd95c4be;hb=e358bd7a3833f8c5bf9db57d228888f9c5f3692e;hpb=0f9091f381191484f1a5ed5189d23cbfa88de6fc diff --git a/lib/PublicInbox/Inbox.pm b/lib/PublicInbox/Inbox.pm index ada713c7..96c92652 100644 --- a/lib/PublicInbox/Inbox.pm +++ b/lib/PublicInbox/Inbox.pm @@ -71,10 +71,14 @@ sub cloneurl { } sub base_url { - my ($self, $prq) = @_; # Plack::Request - if (defined $prq) { - my $url = $prq->base->as_string; - $url .= '/' if $url !~ m!/\z!; # for mount in Plack::Builder + my ($self, $env) = @_; + if ($env) { # PSGI env + my $scheme = $env->{'psgi.url_scheme'}; + my $host_port = $env->{HTTP_HOST} || + "$env->{SERVER_NAME}:$env->{SERVER_PORT}"; + my $url = "$scheme://$host_port". ($env->{SCRIPT_NAME} || '/'); + # for mount in Plack::Builder + $url .= '/' if $url !~ m!/\z!; $url .= $self->{name} . '/'; } else { # either called from a non-PSGI environment (e.g. NNTP/POP3)