Skip to content

Commit

Permalink
Merge pull request #66 from nealio82/master
Browse files Browse the repository at this point in the history
add support for HTTP_HOST server var passed in from Lambda event
  • Loading branch information
mnapoli authored Oct 6, 2018
2 parents 914c29a + 87d7b98 commit 895822a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Bridge/Psr7/RequestFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ public static function fromLambdaEvent(array $event) : ServerRequestInterface
'REQUEST_URI' => $uri,
];

if (isset($headers['Host'])) {
$server['HTTP_HOST'] = $headers['Host'];
}

return new ServerRequest(
$server,
$files,
Expand Down
13 changes: 13 additions & 0 deletions tests/Bridge/Psr7/RequestFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,4 +267,17 @@ public function test POST base64 encoded body is supported()
self::assertEquals('POST', $request->getMethod());
self::assertEquals(['foo' => 'bar'], $request->getParsedBody());
}

public function test HTTP_HOST is set()
{
$request = RequestFactory::fromLambdaEvent([
'headers' => [
'Host' => 'www.example.com',
],
]);

$serverParams = $request->getServerParams();

self::assertSame('www.example.com', $serverParams['HTTP_HOST']);
}
}

0 comments on commit 895822a

Please sign in to comment.