From 3a1b2a22406e1e9f7312e417cdc551e0928700d1 Mon Sep 17 00:00:00 2001 From: "godzilla80@gmx.net" <> Date: Sun, 8 Nov 2009 09:46:55 +0000 Subject: Fix Issue #184 - THttpResponse doesn't support custom Content-Type headers, remove charset part of header if THttpResponse.Charset=false --- HISTORY | 1 + framework/Web/THttpResponse.php | 29 +++++++++++++++++------------ 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/HISTORY b/HISTORY index 3272f185..26f82b3a 100644 --- a/HISTORY +++ b/HISTORY @@ -1,6 +1,7 @@ Version 3.1.7 To be released BUG: Issue#166 - E_NOTICE level error in TDataGatewayCommand (Carl) BUG: Issue#157 - Enabled does not work properly on TActiveRadioButton/CheckBoxList controls (Bradley, Carl) +EHN: Issue#184 - THttpResponse doesn't support custom Content-Type headers, remove charset part of header if THttpResponse.Charset=false (Yves) BUG: Issue#189 - Page State corrupted when EnableStateValidation=False (Christophe) BUG: Issue#198 - "Undefined variable: tagName" after error in application configuration. (Christophe) BUG: Typo in TBoundColumn (Robin) 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