From 7428a0093d7b2a686b804de904acfab6cdbd758e Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Wed, 18 Jan 2017 10:38:03 +0100 Subject: Fix #610 (prado-3.3) --- framework/Web/THttpRequest.php | 10 +++++++++- framework/Web/THttpResponse.php | 18 ++++++++++++++++-- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/framework/Web/THttpRequest.php b/framework/Web/THttpRequest.php index 926cfa46..724c6410 100644 --- a/framework/Web/THttpRequest.php +++ b/framework/Web/THttpRequest.php @@ -533,6 +533,15 @@ class THttpRequest extends TApplicationComponent implements IteratorAggregate,Ar return isset($_SERVER['SERVER_NAME'])?$_SERVER['SERVER_NAME']:null; } + /** + * @return string server software + * @since 3.3.3 + */ + public function getServerSoftware() + { + return isset($_SERVER['SERVER_SOFTWARE'])?$_SERVER['SERVER_SOFTWARE']:null; + } + /** * @return integer server port number */ @@ -1403,4 +1412,3 @@ class THttpRequestUrlFormat extends TEnumerable const Path='Path'; const HiddenPath='HiddenPath'; } - diff --git a/framework/Web/THttpResponse.php b/framework/Web/THttpResponse.php index 93d3c91e..48328c32 100644 --- a/framework/Web/THttpResponse.php +++ b/framework/Web/THttpResponse.php @@ -426,13 +426,28 @@ class THttpResponse extends TModule implements ITextWriter { $this->ensureHeadersSent(); + // Under IIS, explicitly send an HTTP response including the status code + // this is handled automatically by PHP on Apache and others + $isIIS = (stripos($this->getRequest()->getServerSoftware(), "microsoft-iis") !== false); if($url[0]==='/') $url=$this->getRequest()->getBaseUrl().$url; if ($this->_status >= 300 && $this->_status < 400) + { // The status code has been modified to a valid redirection status, send it + if($isIIS) + { + header('HTTP/1.1 ' . $this->_status . ' ' . self::$HTTP_STATUS_CODES[ + array_key_exists($this->_status, self::$HTTP_STATUS_CODES) + ? $this->_status + : 302 + ]); + } header('Location: '.str_replace('&','&',$url), true, $this->_status); - else + } else { + if($isIIS) + header('HTTP/1.1 302 '.self::$HTTP_STATUS_CODES[302]); header('Location: '.str_replace('&','&',$url)); + } if(!$this->getApplication()->getRequestCompleted()) $this->getApplication()->onEndRequest(); @@ -719,4 +734,3 @@ class THttpResponse extends TModule implements ITextWriter return Prado::createComponent($type, $writer); } } - -- cgit v1.2.3