Skip to content

Commit

Permalink
fix(testClient): Support REMOTE_ADDR header
Browse files Browse the repository at this point in the history
  • Loading branch information
ilicmsreten committed Sep 14, 2021
1 parent 86a2a4d commit 7a2719b
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/Bridge/Symfony/Bundle/Test/Client.php
Expand Up @@ -93,14 +93,10 @@ public function request(string $method, string $url, array $options = []): Respo

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

continue;
}

$normalizedHeaderName = strtoupper(str_replace('-', '_', $key));
$header = \in_array($normalizedHeaderName, ['CONTENT_TYPE', 'REMOTE_ADDR'], true) ? $normalizedHeaderName : sprintf('HTTP_%s', $normalizedHeaderName);
// BrowserKit doesn't support setting several headers with the same name
$server['HTTP_'.strtoupper(str_replace('-', '_', $key))] = $value[0] ?? '';
$server[$header] = $value[0] ?? '';
}

if ($basic) {
Expand Down

0 comments on commit 7a2719b

Please sign in to comment.