summaryrefslogtreecommitdiff
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
parent720b474005e2ad8483c669b300d40e10a7ed1cda (diff)
Add method getHeaders to THttpRequest & THttpResponse
-rw-r--r--HISTORY7
-rw-r--r--framework/Web/THttpRequest.php44
-rw-r--r--framework/Web/THttpResponse.php30
3 files changed, 66 insertions, 15 deletions
diff --git a/HISTORY b/HISTORY
index bfd30683..73e48530 100644
--- a/HISTORY
+++ b/HISTORY
@@ -13,6 +13,7 @@ CHG: Modifiy TTemplate::parseAttributes to allow definition of "HTML5 Custom Dat
EHN: Modify TActiveRecordConfig & TActiveRecordManager to allow custom subclassing of System.Data.ActiveRecord.TActiveRecordManager & System.Data.ActiveRecord.TActiveRecordGateway (Yves)
EHN: Add methods quoteTableName, quoteColumnName, quoteColumnAlias to TDbMetaData & TDbConnection and add TDbConnection:getDbMetaData [TODO: customize TOracleMetaData] (Yves)
EHN: Modify TThemeManager to allow custom subclassing of TTheme (Yves)
+EHN: Add method getHeaders to THttpRequest & THttpResponse (Yves)
Version 3.1.9 June 3, 2011
BUG: Issue#280 - Documentation has been updated
@@ -40,7 +41,7 @@ BUG: Issue#226 - TTimerControl fires immediately (rojaro)
BUG: Issue#227 - Clientscript.php return last-modified date header for scripts (rojaro)
BUG: Issue#229 - Typo in TCachePageStatePersister.php (Christophe)
BUG: Issue#230 - TCachingStatement property access not working (rojaro)
-BUG: Issue#232 - Could not change enable-state of TActiveCheckBox via Ajax callback (Christophe)
+BUG: Issue#232 - Could not change enable-state of TActiveCheckBox via Ajax callback (Christophe)
BUG: Issue#233 - THtmlWriter flush() doesn't result the contents of the output buffer (rojaro)
BUG: Issue#234 - Unable to override default HTML writer / pointless THttpResponse::HtmlWriterType (uacaman)
BUG: Issue#236 - Bug in getIsView() in TOracleMetaData (rojaro)
@@ -66,14 +67,14 @@ BUG: Issue#304 - Possible security issue in cookies (rojaro)
BUG: Issue#305 - Password type TTextBox does not support AutoCompleteType (rojaro)
BUG: Issue#319 - When TPanel's DefaultButton property is set to a TActiveButton it inhibits TButton's postbacks (ctrlaltca)
BUG: Issue#324 - TTabPanel doesn't render properly upon postback if a TTabView's visible property = false (ctrlaltca)
-ENH: Security manager: removed the zero byte right trim from the decryption routine and also made some cosmetic changes (rojaro)
+ENH: Security manager: removed the zero byte right trim from the decryption routine and also made some cosmetic changes (rojaro)
ENH: Upgraded the phpunit ini file to work with PHPUnit 3.3 3.4 and 3.5. There are conditionals for 3.3 and 3.4. No more Framework file includes are needed with 3.5. (javalizard)
ENH: Issue#264 - Prado wasting CPU by using ArrayAccess and IteratorAggregate interfaces (uacaman)
ENH: Issue#199/272 - Updated prototype to 1.7 scriptaculous to 1.9.0 and dropped json.js for json2.js. Adds IE9 support (ctrlaltca)
ENH: Updated tinyMCE to latest version (3.4.2). The package size grew up a bit (from 3.7 to 5.5 mb) since the new version is bigger in sizea and adds support for a lot of new localizations. Adds IE9 support (ctrlaltca)
Version 3.1.7 February 22, 2010
-ENH: Issue#24 - Specify needed fields on demand (Yves)
+ENH: Issue#24 - Specify needed fields on demand (Yves)
BUG: Issue#80 - Inconsistencies in TRegularExpressionValidator (Christophe)
BUG: Issue#86 - THttpSession.CookieMode ignored / Session ID leak (Christophe)
BUG: Issue#94 - DataGrid header/footer renderers unable to locate their parent grid in setData() method (Christophe)
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);
}
/**