Skip to content

Commit

Permalink
Fix #3038
Browse files Browse the repository at this point in the history
  • Loading branch information
bcobzh committed Sep 4, 2019
1 parent 4bf6c83 commit 3ffa10b
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/Bridge/Symfony/Bundle/Test/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public function request(string $method, string $url, array $options = []): Respo

$server = [];
// Convert headers to a $_SERVER-like array
foreach ($options['headers'] as $key => $value) {
foreach (self::extractHeaders($options) as $key => $value) {
if ('content-type' === $key) {
$server['CONTENT_TYPE'] = $value[0] ?? '';

Expand Down Expand Up @@ -212,4 +212,25 @@ public function enableReboot(): void
{
$this->kernelBrowser->enableReboot();
}

/**
* Extract headers depending on the symfony/http-client version being used.
*/
private static function extractHeaders(array $options): array
{
if (!isset($options['normalized_headers'])) {
return $options['headers'];
}

$headers = [];

foreach ($options['normalized_headers'] as $key => $values) {
foreach ($values as $value) {
[, $value] = explode(': ', $value, 2);
$headers[$key][] = $value;
}
}

return $headers;
}
}

0 comments on commit 3ffa10b

Please sign in to comment.