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 b943084
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 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,24 @@ public function enableReboot(): void
{
$this->kernelBrowser->enableReboot();
}

/**
* Normalize headers depending on the symfony/http-client version being used.
*
* @return array<string, string[]>
*/
private static function extractHeaders(array $options): array
{
$headers = $options['normalized_headers'] ?? $options['headers'];
foreach ($headers as $key => &$values) {
foreach ($values as &$value) {
$prefix = $key.':';
if (0 === stripos($value, $prefix)) {
$value = ltrim(substr($value, \strlen($prefix)));
}
}
}

return $headers;
}
}

0 comments on commit b943084

Please sign in to comment.