From 6258436ce62988d1178c7c394d5093dbac52056f Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Thu, 23 Oct 2014 22:35:19 +0200 Subject: Fix #539 TErrorHandler: let THttpResponse handle http status codes --- framework/Web/THttpResponse.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'framework/Web') diff --git a/framework/Web/THttpResponse.php b/framework/Web/THttpResponse.php index 75563ef9..7e1afcc6 100644 --- a/framework/Web/THttpResponse.php +++ b/framework/Web/THttpResponse.php @@ -512,10 +512,15 @@ class THttpResponse extends TModule implements ITextWriter */ protected function sendHttpHeader() { - if (($version=$this->getRequest()->getHttpProtocolVersion())==='') - header (' ', true, $this->_status); - else - header($version.' '.$this->_status.' '.$this->_reason, true, $this->_status); + $protocol=$this->getRequest()->getHttpProtocolVersion(); + if($this->getRequest()->getHttpProtocolVersion() === null) + $protocol='HTTP/1.1'; + + $phpSapiName = substr(php_sapi_name(), 0, 3); + $cgi = $phpSapiName == 'cgi' || $phpSapiName == 'fpm'; + + header(($cgi ? 'Status:' : $protocol).' '.$this->_status.' '.$this->_reason, true, TPropertyValue::ensureInteger($this->_status)); + $this->_httpHeaderSent = true; } -- cgit v1.2.3