Created
January 5, 2011 13:13
-
-
Save ajshort/766291 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Index: core/control/Director.php | |
| =================================================================== | |
| --- core/control/Director.php (revision 115357) | |
| +++ core/control/Director.php (working copy) | |
| @@ -112,12 +112,11 @@ | |
| array_merge((array)$_POST, (array)$_FILES), | |
| @file_get_contents('php://input') | |
| ); | |
| - | |
| - // @todo find better way to extract HTTP headers | |
| - if(isset($_SERVER['HTTP_ACCEPT'])) $req->addHeader("Accept", $_SERVER['HTTP_ACCEPT']); | |
| - if(isset($_SERVER['CONTENT_TYPE'])) $req->addHeader("Content-Type", $_SERVER['CONTENT_TYPE']); | |
| - if(isset($_SERVER['HTTP_REFERER'])) $req->addHeader("Referer", $_SERVER['HTTP_REFERER']); | |
| + foreach (sapphire_get_request_headers() as $header => $value) { | |
| + $req->addHeader($header, $value); | |
| + } | |
| + | |
| // Load the session into the controller | |
| $session = new Session(isset($_SESSION) ? $_SESSION : null); | |
| Index: core/Core.php | |
| =================================================================== | |
| --- core/Core.php (revision 115357) | |
| +++ core/Core.php (working copy) | |
| @@ -373,6 +373,35 @@ | |
| } | |
| /** | |
| + * Returns all the HTTP headers that were passed with the current request. | |
| + * | |
| + * @return array | |
| + */ | |
| +function sapphire_get_request_headers() { | |
| + if (function_exists('apache_request_headers')) { | |
| + return apache_request_headers(); | |
| + } | |
| + | |
| + // If we're not running on Apache, then the HTTP headers need to be | |
| + // manually extracted from the $_SERVER array. | |
| + $headers = array(); | |
| + | |
| + foreach ($_SERVER as $key => $value) { | |
| + if (substr($key, 0, 5) == 'HTTP_') { | |
| + $key = substr($key, 5); | |
| + $key = strtolower(str_replace('_', ' ', $key)); | |
| + $key = str_replace(' ', '-', ucwords($key)); | |
| + $headers[$key] = $value; | |
| + } | |
| + } | |
| + | |
| + if(isset($_SERVER['CONTENT_TYPE'])) $headers['Content-Type'] = $_SERVER['CONTENT_TYPE']; | |
| + if(isset($_SERVER['CONTENT_LENGTH'])) $headers['Content-Length'] = $_SERVER['CONTENT_LENGTH']; | |
| + | |
| + return $headers; | |
| +} | |
| + | |
| +/** | |
| * @see i18n::_t() | |
| */ | |
| function _t($entity, $string = "", $priority = 40, $context = "") { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment