summaryrefslogtreecommitdiff
path: root/framework/Web
diff options
context:
space:
mode:
authorgodzilla80@gmx.net <>2010-05-18 07:26:14 +0000
committergodzilla80@gmx.net <>2010-05-18 07:26:14 +0000
commiteaf5175de51166bfc8e192ade2cb26548c056e7c (patch)
tree48c7e3876bfe30ad99ac18b2f34b9dc2de2a76f6 /framework/Web
parent1f0f027fef528ca87a74cad8a12e4684adb6263b (diff)
Change behavior of THttpRequest::getBaseUrl() & THttpRequest::getAbsoluteApplicationUrl() to make it possible to force either http or https
Diffstat (limited to 'framework/Web')
-rw-r--r--framework/Web/THttpRequest.php18
1 files changed, 12 insertions, 6 deletions
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();
}