summaryrefslogtreecommitdiff
path: root/framework/Web/THttpRequest.php
diff options
context:
space:
mode:
authorGODZilla0480@gmail.com <>2011-08-28 09:06:28 +0000
committerGODZilla0480@gmail.com <>2011-08-28 09:06:28 +0000
commitca0ae9bca6fea1a8ef924104b09649e41ea5ab36 (patch)
tree74f7e07a007f7e0b5fe229544a559d59e0fc179a /framework/Web/THttpRequest.php
parent720b474005e2ad8483c669b300d40e10a7ed1cda (diff)
Add method getHeaders to THttpRequest & THttpResponse
Diffstat (limited to 'framework/Web/THttpRequest.php')
-rw-r--r--framework/Web/THttpRequest.php44
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');
+ }
}
/**