fix: http.core.HttpRequest (now manages both Apache/nginx, especially php-fpm because the function 'getallheaders()' is not available, so gess it from (solution from http://php.net/manual/en/function.getallheaders.php\#84262))
This commit is contained in:
parent
f1c338853f
commit
0c0f34c7d4
|
@ -42,7 +42,7 @@
|
||||||
|
|
||||||
/* [2] Define headers
|
/* [2] Define headers
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
$this->headers = \getallheaders();
|
$this->headers = self::getallheaders_adapter();
|
||||||
|
|
||||||
|
|
||||||
/* [3] Define default datasets (GET, POST)
|
/* [3] Define default datasets (GET, POST)
|
||||||
|
@ -201,4 +201,30 @@
|
||||||
public function HEADERS(){ return $this->headers; }
|
public function HEADERS(){ return $this->headers; }
|
||||||
public function METHOD(){ return $this->method; }
|
public function METHOD(){ return $this->method; }
|
||||||
public function URI(){ return $this->uri; }
|
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;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue