diff --git a/build/http/core/HttpRequest.php b/build/http/core/HttpRequest.php index 312a480..f2d919a 100644 --- a/build/http/core/HttpRequest.php +++ b/build/http/core/HttpRequest.php @@ -42,7 +42,7 @@ /* [2] Define headers =========================================================*/ - $this->headers = \getallheaders(); + $this->headers = self::getallheaders_adapter(); /* [3] Define default datasets (GET, POST) @@ -201,4 +201,30 @@ public function HEADERS(){ return $this->headers; } public function METHOD(){ return $this->method; } public function URI(){ return $this->uri; } + + + private static function getallheaders_adapter(){ + /* (1) If exists -> use it + ---------------------------------------------------------*/ + if( function_exists('getallheaders') ) + return getallheaders(); + + /* (2) If does not (php-fpm) + ---------------------------------------------------------*/ + /* (1) init. variables */ + $fetched_headers = []; + + /* (2) Get all headers from $_SERVER */ + foreach($_SERVER as $hname=>$hvalue ){ + + // {1} Store only if begins with 'HTTP_' // + if( substr($hname,0,5) == 'HTTP_' ) + $fetched_headers[ str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($hname,5)))))] = $hvalue; + + } + + /* (3) Return created headers */ + return $fetched_headers; + + } }