]> Sergey Matveev's repositories - public-inbox.git/commitdiff
allow HTTP_HOST to be '0' via defined() checks
authorEric Wong <e@yhbt.net>
Fri, 10 Jan 2020 09:14:16 +0000 (09:14 +0000)
committerEric Wong <e@yhbt.net>
Sat, 11 Jan 2020 06:32:08 +0000 (06:32 +0000)
'0' is a valid value for HTTP_HOST, and maybe some folks
will want to hit that as port 80 where the HTTP client won't
send the ":$PORT" suffix.

lib/PublicInbox/Git.pm
lib/PublicInbox/HTTP.pm

index 6a527f82f9145ada72a1abbf053bf1987009283d..2aaf1866b5965169e4abcec87f1fdaed9b6fb47c 100644 (file)
@@ -300,7 +300,7 @@ sub host_prefix_url ($$) {
        my ($env, $url) = @_;
        return $url if index($url, '//') >= 0;
        my $scheme = $env->{'psgi.url_scheme'};
-       my $host_port = $env->{HTTP_HOST} ||
+       my $host_port = $env->{HTTP_HOST} //
                "$env->{SERVER_NAME}:$env->{SERVER_PORT}";
        "$scheme://$host_port". ($env->{SCRIPT_NAME} || '/') . $url;
 }
index a6ec1d0d7388540e2ace1a90ae16751f641297aa..071251c632e394302097538bf86ed881473a6fe5 100644 (file)
@@ -155,7 +155,7 @@ sub app_dispatch {
        my $env = $self->{env};
        $env->{REMOTE_ADDR} = $self->{remote_addr};
        $env->{REMOTE_PORT} = $self->{remote_port};
-       if (my $host = $env->{HTTP_HOST}) {
+       if (defined(my $host = $env->{HTTP_HOST})) {
                $host =~ s/:([0-9]+)\z// and $env->{SERVER_PORT} = $1;
                $env->{SERVER_NAME} = $host;
        }