Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #287 from doy/master

Host header needs to include non-default port information
  • Loading branch information...
commit 6593fb8388e43539aa0771de6fe280c87c4ec9b2 2 parents 259dad5 + e27c5fb
@miyagawa miyagawa authored
Showing with 10 additions and 0 deletions.
  1. +2 −0  lib/HTTP/Message/PSGI.pm
  2. +8 −0 t/HTTP-Message-PSGI/host.t
View
2  lib/HTTP/Message/PSGI.pm
@@ -84,6 +84,8 @@ sub req_to_psgi {
if (!defined($env->{HTTP_HOST}) && $req->uri->can('host')) {
$env->{HTTP_HOST} = $req->uri->host;
+ $env->{HTTP_HOST} .= ':' . $req->uri->port
+ if $req->uri->port ne $req->uri->default_port;
}
return $env;
View
8 t/HTTP-Message-PSGI/host.t
@@ -13,6 +13,14 @@ use HTTP::Request;
}
{
+ my $req = HTTP::Request->new(GET => "http://example.com:345/");
+ my $env = req_to_psgi $req;
+
+ is $env->{HTTP_HOST}, 'example.com:345';
+ is $env->{PATH_INFO}, '/';
+}
+
+{
my $req = HTTP::Request->new(GET => "/");
$req->header('Host' => "perl.com");
my $env = req_to_psgi $req;
Please sign in to comment.
Something went wrong with that request. Please try again.