summaryrefslogtreecommitdiff
path: root/framework/Web/THttpResponse.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/THttpResponse.php
parent720b474005e2ad8483c669b300d40e10a7ed1cda (diff)
Add method getHeaders to THttpRequest & THttpResponse
Diffstat (limited to 'framework/Web/THttpResponse.php')
-rw-r--r--framework/Web/THttpResponse.php30
1 files changed, 27 insertions, 3 deletions
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);
}
/**