diff options
author | Alex <[email protected]> | 2019-01-16 20:29:06 -0800 |
---|---|---|
committer | Alex <[email protected]> | 2019-01-16 20:29:06 -0800 |
commit | 16eadf280de86de4615347af2ee7a36f35efc8ca (patch) | |
tree | 9a957cfa3d150f953321fe7320952be9d68e9405 /src | |
parent | 09db9ec8300912668dea72b90c07d3e1cb37bd88 (diff) |
Fix headers in _SERVER (laravel integration fix)
Diffstat (limited to 'src')
-rw-r--r-- | src/PSR7Client.php | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/PSR7Client.php b/src/PSR7Client.php index 1136ce10..d8ec4405 100644 --- a/src/PSR7Client.php +++ b/src/PSR7Client.php @@ -146,9 +146,13 @@ class PSR7Client $server['REMOTE_ADDR'] = $ctx['attributes']['ipAddress'] ?? $ctx['remoteAddr'] ?? '127.0.0.1'; $server['REMOTE_ADDR'] = $ctx['attributes']['ipAddress'] ?? $ctx['remoteAddr'] ?? '127.0.0.1'; - $server['HTTP_USER_AGENT'] = ''; - if (isset($ctx['headers']['User-Agent'][0])) { - $server['HTTP_USER_AGENT'] = $ctx['headers']['User-Agent'][0]; + foreach ($ctx['headers'] as $key => $value) { + $key = strtoupper(str_replace('-', '_', $key)); + if (\in_array($key, array('CONTENT_TYPE', 'CONTENT_LENGTH'))) { + $_SERVER[$key] = implode(', ', $value); + } else { + $_SERVER['HTTP_' . $key] = implode(', ', $value); + } } return $server; |