From 9989e51f6fc6935a5aaf95a3f272a7f4f079c131 Mon Sep 17 00:00:00 2001 From: Exodus4D Date: Tue, 10 Nov 2015 20:30:21 +0100 Subject: [PATCH] close #58 Added fallback for non Apache servers to receive corrent HEADER data --- app/main/controller/controller.php | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/app/main/controller/controller.php b/app/main/controller/controller.php index b20c4964..e2bc503e 100644 --- a/app/main/controller/controller.php +++ b/app/main/controller/controller.php @@ -206,14 +206,23 @@ class Controller { * @return array (string $key -> string $value) */ static function getRequestHeaders(){ - $headers = ''; - foreach ($_SERVER as $name => $value) - { - if (substr($name, 0, 5) == 'HTTP_') - { - $headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value; + $headers = []; + + if(function_exists('apache_request_headers') ){ + // Apache Webserver + $headers = apache_request_headers(); + }else{ + // Other webserver, e.g. nginx + // Unfortunately this "fallback" does not work for me (Apache) + // Therefore we can“t use this for all servers + // https://github.com/exodus4d/pathfinder/issues/58 + foreach($_SERVER as $name => $value){ + if(substr($name, 0, 5) == 'HTTP_'){ + $headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value; + } } } + return $headers; }