Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/GlobalState.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,17 @@ public static function enrichServerVars(Request $request): array
$server['REQUEST_METHOD'] = $request->method;
$server['HTTP_USER_AGENT'] = '';

$host = parse_url($request->uri, PHP_URL_HOST);
$port = parse_url($request->uri, PHP_URL_PORT);

if ($host != null) {
$server['HTTP_HOST'] = $host;
}

if ($host != null && $port != null) {
$server['HTTP_HOST'] = $host . ':' . $port;
}

Comment thread
roxblnfk marked this conversation as resolved.
Outdated
foreach ($request->headers as $key => $value) {
$key = \strtoupper(\str_replace('-', '_', $key));

Expand Down
2 changes: 2 additions & 0 deletions tests/Unit/PSR7WorkerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public function testStateServerLeak(): void
'HTTP_USER_AGENT' => '',
'CONTENT_TYPE' => 'application/html',
'HTTP_CONNECTION' => 'keep-alive',
'HTTP_HOST' => 'localhost',
],
],
[
Expand All @@ -56,6 +57,7 @@ public function testStateServerLeak(): void
'REQUEST_METHOD' => 'GET',
'HTTP_USER_AGENT' => '',
'CONTENT_TYPE' => 'application/json',
'HTTP_HOST' => 'localhost',
],
],
];
Expand Down
Loading