]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/Inbox.pm
wwwstream: allow undef noop callback
[public-inbox.git] / lib / PublicInbox / Inbox.pm
index ada713c741657ef16522d4b118cffebcbd95c4be..728caa0c3f9e059da3a42ecf4019fbb8b66c881c 100644 (file)
@@ -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)
@@ -104,6 +108,11 @@ sub msg_by_path ($$;$) {
        $str;
 }
 
+sub path_check {
+       my ($self, $path) = @_;
+       git($self)->check('HEAD:'.$path);
+}
+
 sub msg_by_mid ($$;$) {
        my ($self, $mid, $ref) = @_;
        msg_by_path($self, mid2path($mid), $ref);