Skip to content
Snippets Groups Projects
Unverified Commit a1bf3411 authored by Tim van Dijen's avatar Tim van Dijen Committed by GitHub
Browse files

rewrite getServerPort

Also fixes edge-case situation where $_SERVER['SERVER_PORT'] is not set for an HTTPS connection, this function would return an explicit port 80 i.e. ":80" rather than an empty string.
parent 8a4504c5
Branches
Tags
No related merge requests found
...@@ -108,15 +108,11 @@ class HTTP ...@@ -108,15 +108,11 @@ class HTTP
*/ */
public static function getServerPort() public static function getServerPort()
{ {
$port = (isset($_SERVER['SERVER_PORT'])) ? $_SERVER['SERVER_PORT'] : '80'; $default_port = self::getServerHTTPS() ? '443' : '80';
if (self::getServerHTTPS()) { $port = isset($_SERVER['SERVER_PORT']) ? $_SERVER['SERVER_PORT'] : $default_port;
if ($port !== '443') {
return ':'.$port; if ($port !== $default_port) {
} return ':'.$port;
} else {
if ($port !== '80') {
return ':'.$port;
}
} }
return ''; return '';
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment