diff --git a/lib/SimpleSAML/Utils/HTTP.php b/lib/SimpleSAML/Utils/HTTP.php index d14d71e5a9f2d7d18c6ed51aad0e0ea1120f6e42..88eadf5c42bb6debd71ea13113a059606b04afa4 100644 --- a/lib/SimpleSAML/Utils/HTTP.php +++ b/lib/SimpleSAML/Utils/HTTP.php @@ -108,15 +108,11 @@ class HTTP */ public static function getServerPort() { - $port = (isset($_SERVER['SERVER_PORT'])) ? $_SERVER['SERVER_PORT'] : '80'; - if (self::getServerHTTPS()) { - if ($port !== '443') { - return ':'.$port; - } - } else { - if ($port !== '80') { - return ':'.$port; - } + $default_port = self::getServerHTTPS() ? '443' : '80'; + $port = isset($_SERVER['SERVER_PORT']) ? $_SERVER['SERVER_PORT'] : $default_port; + + if ($port !== $default_port) { + return ':'.$port; } return ''; }