From 8f4720a57d9c5746dcf53fa6c612350c744c2cd1 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 10 Jan 2020 09:14:16 +0000 Subject: allow HTTP_HOST to be '0' via defined() checks '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 | 2 +- lib/PublicInbox/HTTP.pm | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/PublicInbox') diff --git a/lib/PublicInbox/Git.pm b/lib/PublicInbox/Git.pm index 6a527f82..2aaf1866 100644 --- a/lib/PublicInbox/Git.pm +++ b/lib/PublicInbox/Git.pm @@ -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; } diff --git a/lib/PublicInbox/HTTP.pm b/lib/PublicInbox/HTTP.pm index a6ec1d0d..071251c6 100644 --- a/lib/PublicInbox/HTTP.pm +++ b/lib/PublicInbox/HTTP.pm @@ -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; } -- cgit v1.2.3-24-ge0c7