From a47699ed29b12bb885c5912ccef533e13664e9ab Mon Sep 17 00:00:00 2001 From: debuss Date: Wed, 21 Aug 2019 14:42:06 +0700 Subject: [PATCH] Fixed headers for ServerRequest. --- composer.json | 3 ++- src/Http/ServerRequest.php | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 7db880b..ddb5c40 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,8 @@ ], "require": { "psr/http-message": "^1.0", - "psr/http-factory": "^1.0" + "psr/http-factory": "^1.0", + "ralouphie/getallheaders": "3.0.3" }, "autoload": { "psr-4": { diff --git a/src/Http/ServerRequest.php b/src/Http/ServerRequest.php index 5d5c50d..6636aca 100644 --- a/src/Http/ServerRequest.php +++ b/src/Http/ServerRequest.php @@ -50,6 +50,15 @@ public function __construct(string $method, $uri, array $server = null) $this->attributes = []; $this->uploaded_files = Helper::getUploadedFilesFromGlobal(); + + foreach (getallheaders() as $header => $value) { + $header = trim((string)$header); + if (!isset($this->headers[$header])) { + $this->headers[$header] = []; + } + + $this->headers[$header] = array_merge($this->headers[$header], $value); + } } /**