summaryrefslogtreecommitdiffstats
path: root/lib/SimpleSAML/Utils/HTTP.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/SimpleSAML/Utils/HTTP.php')
-rw-r--r--lib/SimpleSAML/Utils/HTTP.php29
1 files changed, 16 insertions, 13 deletions
diff --git a/lib/SimpleSAML/Utils/HTTP.php b/lib/SimpleSAML/Utils/HTTP.php
index c25bc6d..00946fc 100644
--- a/lib/SimpleSAML/Utils/HTTP.php
+++ b/lib/SimpleSAML/Utils/HTTP.php
@@ -595,32 +595,35 @@ class HTTP
/**
* Retrieve our own host.
*
- * @return string The current host (with non-default ports included).
+ * E.g. www.example.com
*
- * @author Andreas Solberg, UNINETT AS <andreas.solberg@uninett.no>
- * @author Olav Morken, UNINETT AS <olav.morken@uninett.no>
+ * @return string The current host.
+ *
+ * @author Jaime Perez, UNINETT AS <jaime.perez@uninett.no>
*/
public static function getSelfHost()
{
- $url = self::getBaseURL();
-
- $start = strpos($url, '://') + 3;
- $length = strcspn($url, '/', $start);
-
- return substr($url, $start, $length);
+ return array_shift(explode(':', self::getSelfHostWithNonStandardPort()));
}
/**
- * Retrieve our own host.
+ * Retrieve our own host, including the port in case the it is not standard for the protocol in use. That is port
+ * 80 for HTTP and port 443 for HTTPS.
+ *
+ * E.g. www.example.com:8080
*
- * @return string The current host without port specification.
+ * @return string The current host, followed by a colon and the port number, in case the port is not standard for
+ * the protocol.
+ *
+ * @author Andreas Solberg, UNINETT AS <andreas.solberg@uninett.no>
+ * @author Olav Morken, UNINETT AS <olav.morken@uninett.no>
*/
- public static function getSelfHostWithoutPort()
+ public static function getSelfHostWithNonStandardPort()
{
$url = self::getBaseURL();
$start = strpos($url, '://') + 3;
- $length = strcspn($url, '/:', $start);
+ $length = strcspn($url, '/', $start);
return substr($url, $start, $length);
}