/** * Build an array of the request headers by hand. Replacement for using * apache_request_headers(), which only works in certain configurations. * This solution gets them from the $_SERVER array, and re-munges them back * from HTTP_FOO_BAR format to Foo-Bar format. Stolen from: * http://stackoverflow.com/questions/541430/how-do-i-read-any-request-header-in-php * * @return array request headers assoc */ public static function parseRequestHeaders() { if (isset(self::$requestHeaders)) { return self::$requestHeaders; } self::$requestHeaders = array(); foreach ($_SERVER as $key => $value) { if (substr($key, 0, 5) != 'HTTP_') { continue; } $header = str_replace(' ', '-', ucwords(str_replace('_', ' ', strtolower(substr($key, 5))))); self::$requestHeaders[$header] = $value; } return self::$requestHeaders; }