diff options
Diffstat (limited to 'framework/Web/THttpRequest.php')
-rw-r--r-- | framework/Web/THttpRequest.php | 44 |
1 files changed, 35 insertions, 9 deletions
diff --git a/framework/Web/THttpRequest.php b/framework/Web/THttpRequest.php index 6529fdae..142b5813 100644 --- a/framework/Web/THttpRequest.php +++ b/framework/Web/THttpRequest.php @@ -343,7 +343,7 @@ class THttpRequest extends TApplicationComponent implements IteratorAggregate,Ar */ public function getIsSecureConnection() { - return isset($_SERVER['HTTPS']) && strcasecmp($_SERVER['HTTPS'],'off'); + return isset($_SERVER['HTTPS']) && strcasecmp($_SERVER['HTTPS'],'off'); } /** @@ -371,6 +371,32 @@ class THttpRequest extends TApplicationComponent implements IteratorAggregate,Ar } /** + * @param integer|null Either {@link CASE_UPPER} or {@link CASE_LOWER} or as is null (default) + * @return array + */ + public function getHeaders($case=null) + { + static $result; + + if($result === null && function_exists('apache_request_headers')) { + $result = apache_request_headers(); + } + elseif($result === null) { + $result = array(); + foreach($_SERVER as $key=>$value) { + if(strncasecmp($key, 'HTTP_', 5) !== 0) continue; + $key = str_replace(' ','-', ucwords(strtolower(str_replace('_',' ', substr($key, 5))))); + $result[$key] = $value; + } + } + + if($case !== null) + return array_change_key_case($result, $case); + + return $result; + } + + /** * @return string part of that request URL after the host info (including pathinfo and query string) */ public function getRequestUri() @@ -455,14 +481,14 @@ class THttpRequest extends TApplicationComponent implements IteratorAggregate,Ar */ public function getBrowser() { - try - { - return get_browser(); - } - catch(TPhpErrorException $e) - { - throw new TConfigurationException('httprequest_browscap_required'); - } + try + { + return get_browser(); + } + catch(TPhpErrorException $e) + { + throw new TConfigurationException('httprequest_browscap_required'); + } } /** |