added headers for module
This commit is contained in:
parent
c99432d717
commit
b0cab299e2
@ -13,6 +13,8 @@ class Crunchbutton_App extends Cana_App {
|
||||
private $_crypt;
|
||||
public function init($params = null) {
|
||||
set_exception_handler([$this, 'exception']);
|
||||
Crunchbutton_Headers;
|
||||
|
||||
if (!$_SERVER['SERVER_NAME']) {
|
||||
$cli = true;
|
||||
// get the env send by parameter
|
||||
|
||||
52
include/library/Crunchbutton/Headers.php
Normal file
52
include/library/Crunchbutton/Headers.php
Normal file
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
// Drop-in replacement for apache_request_headers() when it's not available
|
||||
|
||||
class Crunchbutton_Headers{}
|
||||
|
||||
if(!function_exists('apache_request_headers')) {
|
||||
function apache_request_headers() {
|
||||
|
||||
// Based on: http://www.iana.org/assignments/message-headers/message-headers.xml#perm-headers
|
||||
$arrCasedHeaders = array(
|
||||
// HTTP
|
||||
'Dasl' => 'DASL',
|
||||
'Dav' => 'DAV',
|
||||
'Etag' => 'ETag',
|
||||
'Mime-Version' => 'MIME-Version',
|
||||
'Slug' => 'SLUG',
|
||||
'Te' => 'TE',
|
||||
'Www-Authenticate' => 'WWW-Authenticate',
|
||||
// MIME
|
||||
'Content-Md5' => 'Content-MD5',
|
||||
'Content-Id' => 'Content-ID',
|
||||
'Content-Features' => 'Content-features',
|
||||
);
|
||||
$arrHttpHeaders = array();
|
||||
|
||||
foreach($_SERVER as $strKey => $mixValue) {
|
||||
if('HTTP_' !== substr($strKey, 0, 5)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$strHeaderKey = strtolower(substr($strKey, 5));
|
||||
|
||||
if(0 < substr_count($strHeaderKey, '_')) {
|
||||
$arrHeaderKey = explode('_', $strHeaderKey);
|
||||
$arrHeaderKey = array_map('ucfirst', $arrHeaderKey);
|
||||
$strHeaderKey = implode('-', $arrHeaderKey);
|
||||
}
|
||||
else {
|
||||
$strHeaderKey = ucfirst($strHeaderKey);
|
||||
}
|
||||
|
||||
if(array_key_exists($strHeaderKey, $arrCasedHeaders)) {
|
||||
$strHeaderKey = $arrCasedHeaders[$strHeaderKey];
|
||||
}
|
||||
|
||||
$arrHttpHeaders[$strHeaderKey] = $mixValue;
|
||||
}
|
||||
|
||||
return $arrHttpHeaders;
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user