diff --git a/backend/lib/View/HTTP/Request.php b/backend/lib/View/HTTP/Request.php index 57f6f0d..c9dbdf6 100644 --- a/backend/lib/View/HTTP/Request.php +++ b/backend/lib/View/HTTP/Request.php @@ -60,7 +60,11 @@ class Request { } protected static function getHeaders() { - if (!function_exists('apache_request_headers')) { + if (function_exists('apache_request_headers')) { + return apache_request_headers(); + } + else { + $headers = array(); foreach ($_SERVER as $name => $value) { if (substr($name, 0, 5) == 'HTTP_') { $headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value; @@ -68,9 +72,6 @@ class Request { } return $headers; } - else { - return apache_request_headers(); - } } /** diff --git a/backend/lib/View/HTTP/Response.php b/backend/lib/View/HTTP/Response.php index b59cbc4..a5e538b 100644 --- a/backend/lib/View/HTTP/Response.php +++ b/backend/lib/View/HTTP/Response.php @@ -82,11 +82,25 @@ class Response { * constructor */ public function __construct() { - $this->headers = apache_response_headers(); + $this->headers = self::getHeaders(); ob_start(array($this, 'obCallback')); } + protected static function getHeaders() { + if (function_exists('apache_response_headers')) { + return apache_response_headers(); + } + else { + $headers = array(); + foreach (headers_list() as $header) { + $sp = strpos($header, ':'); + $headers[substr($header, 0, $sp)] = substr($header, $sp); + } + return $headers; + } + } + public function obCallback($output) { return $output; // simple passthrough }