From 94e94e0a8566f23d16658a04c55b0bbfdd6689aa Mon Sep 17 00:00:00 2001 From: "godzilla80@gmx.net" <> Date: Sun, 14 Feb 2010 01:22:57 +0000 Subject: Merge Branches & Trunk /trunk:r2680,2692,2707-2736 /branches/3.1:r2682-2686,2694-2702,2705,2738-2762 --- framework/Web/THttpResponse.php | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) (limited to 'framework/Web/THttpResponse.php') diff --git a/framework/Web/THttpResponse.php b/framework/Web/THttpResponse.php index 3222f22f..c15f2836 100644 --- a/framework/Web/THttpResponse.php +++ b/framework/Web/THttpResponse.php @@ -66,6 +66,9 @@ Prado::using('System.Web.THttpResponseAdapter'); */ class THttpResponse extends TModule implements ITextWriter { + const DEFAULT_CONTENTTYPE = 'text/html'; + const DEFAULT_CHARSET = 'UTF-8'; + /** * @var The differents defined status code by RFC 2616 {@link http://www.faqs.org/rfcs/rfc2616} */ @@ -106,7 +109,7 @@ class THttpResponse extends TModule implements ITextWriter */ private $_contentType=null; /** - * @var string character set, e.g. UTF-8 + * @var string|boolean character set, e.g. UTF-8 or false if no character set should be send to client */ private $_charset=''; /** @@ -212,7 +215,7 @@ class THttpResponse extends TModule implements ITextWriter } /** - * @return string output charset. + * @return string|boolean output charset. */ public function getCharset() { @@ -220,11 +223,11 @@ class THttpResponse extends TModule implements ITextWriter } /** - * @param string output charset. + * @param string|boolean output charset. */ public function setCharset($charset) { - $this->_charset = $charset; + $this->_charset = (strToLower($charset) === 'false') ? false : (string)$charset; } /** @@ -465,20 +468,22 @@ class THttpResponse extends TModule implements ITextWriter } /** - * Sends content type header if charset is not empty. + * Sends content type header with optional charset. */ protected function sendContentTypeHeader() { + $contentType=$this->_contentType===null?self::DEFAULT_CONTENTTYPE:$this->_contentType; $charset=$this->getCharset(); + if($charset === false) { + $this->appendHeader('Content-Type: '.$contentType); + return; + } + if($charset==='' && ($globalization=$this->getApplication()->getGlobalization(false))!==null) $charset=$globalization->getCharset(); - if($charset!=='') - { - $contentType=$this->_contentType===null?'text/html':$this->_contentType; - $this->appendHeader('Content-Type: '.$contentType.';charset='.$charset); - } - else if($this->_contentType!==null) - $this->appendHeader('Content-Type: '.$this->_contentType.';charset=UTF-8'); + + if($charset==='') $charset = self::DEFAULT_CHARSET; + $this->appendHeader('Content-Type: '.$contentType.';charset='.$charset); } /** -- cgit v1.2.3