From b0cab299e2227f14752f5e513f7002ac11d067e3 Mon Sep 17 00:00:00 2001 From: Devin Smith Date: Thu, 26 Feb 2015 14:55:45 -0800 Subject: [PATCH] added headers for module --- include/library/Crunchbutton/App.php | 2 + include/library/Crunchbutton/Headers.php | 52 ++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 include/library/Crunchbutton/Headers.php diff --git a/include/library/Crunchbutton/App.php b/include/library/Crunchbutton/App.php index 757434c5b..5d84f853f 100755 --- a/include/library/Crunchbutton/App.php +++ b/include/library/Crunchbutton/App.php @@ -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 diff --git a/include/library/Crunchbutton/Headers.php b/include/library/Crunchbutton/Headers.php new file mode 100644 index 000000000..7660d35bb --- /dev/null +++ b/include/library/Crunchbutton/Headers.php @@ -0,0 +1,52 @@ + '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; + + } +} \ No newline at end of file