Permalink
Browse files

Host header needs to include port information too

  • Loading branch information...
1 parent 259dad5 commit e27c5fb06f942f7ad46c3e3842a91bba294d1960 @doy doy committed May 11, 2012
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
@@ -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;
@@ -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;

0 comments on commit e27c5fb

Please sign in to comment.