Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion src/Event/Http/Psr7Bridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public static function convertRequest(HttpRequestEvent $event, Context $context)
'REQUEST_URI' => $event->getUri(),
'PHP_AUTH_USER' => $user,
'PHP_AUTH_PW' => $password,
]);
], fn ($value) => $value !== null);

foreach ($headers as $name => $values) {
$server['HTTP_' . strtoupper(str_replace('-', '_', (string) $name))] = $values[0];
Expand Down
17 changes: 17 additions & 0 deletions tests/Event/Http/Psr7BridgeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,23 @@ public function test I can create a response from a PSR7 response()
], $response->toApiGatewayFormat());
}

public function test falsy server params are not dropped()
{
$event = new HttpRequestEvent([
'httpMethod' => 'GET',
'headers' => [
'Content-Length' => '0',
'Authorization' => 'Basic ' . base64_encode('user:'),
],
]);
$request = Psr7Bridge::convertRequest($event, Context::fake());

$serverParams = $request->getServerParams();
self::assertSame('0', $serverParams['CONTENT_LENGTH']);
self::assertSame('user', $serverParams['PHP_AUTH_USER']);
self::assertSame('', $serverParams['PHP_AUTH_PW']);
}

protected function fromFixture(string $file): void
{
$event = new HttpRequestEvent(json_decode(file_get_contents($file), true, 512, JSON_THROW_ON_ERROR));
Expand Down
Loading