From eaf5175de51166bfc8e192ade2cb26548c056e7c Mon Sep 17 00:00:00 2001 From: "godzilla80@gmx.net" <> Date: Tue, 18 May 2010 07:26:14 +0000 Subject: Change behavior of THttpRequest::getBaseUrl() & THttpRequest::getAbsoluteApplicationUrl() to make it possible to force either http or https --- framework/Web/THttpRequest.php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'framework/Web') diff --git a/framework/Web/THttpRequest.php b/framework/Web/THttpRequest.php index 26630c8c..ed981c90 100644 --- a/framework/Web/THttpRequest.php +++ b/framework/Web/THttpRequest.php @@ -357,7 +357,7 @@ class THttpRequest extends TApplicationComponent implements IteratorAggregate,Ar { return isset($_SERVER['SERVER_PROTOCOL'])?$_SERVER['SERVER_PROTOCOL']:''; } - + /** * @return string part of that request URL after the host info (including pathinfo and query string) */ @@ -367,13 +367,16 @@ class THttpRequest extends TApplicationComponent implements IteratorAggregate,Ar } /** - * @param boolean whether to use HTTPS instead of HTTP even if the current request is sent via HTTP + * @param boolean|null whether to use HTTPS instead of HTTP even if the current request is sent via HTTP or vice versa + * null - keep current schema + * true - force https + * false - force http * @return string schema and hostname of the requested URL */ - public function getBaseUrl($forceSecureConnection=false) + public function getBaseUrl($forceSecureConnection=null) { $url=$this->getUrl(); - $scheme=($forceSecureConnection)?"https":$url->getScheme(); + $scheme=($forceSecureConnection)?"https": (($forceSecureConnection === null)?$url->getScheme():'http'); $host=$url->getHost(); if (($port=$url->getPort())) $host.=':'.$port; return $scheme.'://'.$host; @@ -388,10 +391,13 @@ class THttpRequest extends TApplicationComponent implements IteratorAggregate,Ar } /** - * @param boolean whether to use HTTPS instead of HTTP even if the current request is sent via HTTP + * @param boolean|null whether to use HTTPS instead of HTTP even if the current request is sent via HTTP or vice versa + * null - keep current schema + * true - force https + * false - force http * @return string entry script URL (w/ host part) */ - public function getAbsoluteApplicationUrl($forceSecureConnection=false) + public function getAbsoluteApplicationUrl($forceSecureConnection=null) { return $this->getBaseUrl($forceSecureConnection) . $this->getApplicationUrl(); } -- cgit v1.2.3