added workaround for non-Apache webservers
This commit is contained in:
parent
1e4f997f3a
commit
9a72d549a1
2 changed files with 20 additions and 5 deletions
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue