Skip to content

Commit

Permalink
Flat map headers for PSR request context
Browse files Browse the repository at this point in the history
The PSR request headers come in a weird format. We'll flatten the array to a simple key-value format
  • Loading branch information
AlexVanderbist committed May 11, 2022
1 parent b8f1b2b commit 47302e8
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/Context/RequestContextProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,15 @@ public function getCookies(): array
*/
public function getHeaders(): array
{
return $this->request->headers->all();
/** @var array<string, list<string|null>> $headers */
$headers = $this->request->headers->all();

return array_filter(
array_map(
fn(array $header) => $header[0],
$headers
)
);
}

/**
Expand Down

0 comments on commit 47302e8

Please sign in to comment.