summaryrefslogtreecommitdiff
path: root/framework/Web
diff options
context:
space:
mode:
Diffstat (limited to 'framework/Web')
-rw-r--r--framework/Web/THttpRequest.php44
-rw-r--r--framework/Web/THttpResponse.php30
2 files changed, 62 insertions, 12 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');
+ }
}
/**
diff --git a/framework/Web/THttpResponse.php b/framework/Web/THttpResponse.php
index 1f314dda..9ef55b76 100644
--- a/framework/Web/THttpResponse.php
+++ b/framework/Web/THttpResponse.php
@@ -476,10 +476,10 @@ class THttpResponse extends TModule implements ITextWriter
{
Prado::trace("Flushing output",'System.Web.THttpResponse');
$this->ensureHeadersSent();
- if($this->_bufferOutput)
+ if($this->_bufferOutput)
{
// avoid forced send of http headers (ob_flush() does that) if there's no output yet
- if (ob_get_length()>0)
+ if (ob_get_length()>0)
{
if (!$continueBuffering)
{
@@ -569,6 +569,30 @@ class THttpResponse extends TModule implements ITextWriter
}
/**
+ * @param integer|null Either {@link CASE_UPPER} or {@link CASE_LOWER} or as is null (default)
+ * @return array
+ */
+ public function getHeaders($case=null)
+ {
+ $result = array();
+ $headers = headers_list();
+ foreach($headers as $header) {
+ $tmp = explode(':', $header);
+ $key = trim(array_shift($tmp));
+ $value = trim(implode(':', $tmp));
+ if(isset($result[$key]))
+ $result[$key] .= ', ' . $value;
+ else
+ $result[$key] = $value;
+ }
+
+ if($case !== null)
+ return array_change_key_case($result, $case);
+
+ return $result;
+ }
+
+ /**
* Sends a header.
* @param string header
* @param boolean whether the header should replace a previous similar header, or add a second header of the same type
@@ -673,7 +697,7 @@ class THttpResponse extends TModule implements ITextWriter
if($this->getHasAdapter())
return $this->_adapter->createNewHtmlWriter($type, $this);
else
- return $this->createNewHtmlWriter($type, $this);
+ return $this->createNewHtmlWriter($type, $this);
}
/**