Skip to content
Snippets Groups Projects
Commit e19f7748 authored by Tim van Dijen's avatar Tim van Dijen
Browse files

Fix edge-case #594 with integer SERVER_PORT

parent 4e2e7fd6
No related branches found
No related tags found
No related merge requests found
......@@ -110,6 +110,9 @@ class HTTP
{
$default_port = self::getServerHTTPS() ? '443' : '80';
$port = isset($_SERVER['SERVER_PORT']) ? $_SERVER['SERVER_PORT'] : $default_port;
// Take care of edge-case where SERVER_PORT is an integer
$port = strval($port);
if ($port !== $default_port) {
return ':'.$port;
......
......@@ -366,6 +366,10 @@ class HTTPTest extends TestCase
$_SERVER['SERVER_PORT'] = '80';
$this->assertEquals(HTTP::getServerPort(), '');
// Test HTTP + standard integer port
$_SERVER['SERVER_PORT'] = 80;
$this->assertEquals(HTTP::getServerPort(), '');
// Test HTTP + without port
unset($_SERVER['SERVER_PORT']);
$this->assertEquals(HTTP::getServerPort(), '');
......@@ -375,6 +379,10 @@ class HTTPTest extends TestCase
$_SERVER['SERVER_PORT'] = '3030';
$this->assertEquals(HTTP::getServerPort(), ':3030');
// Test HTTPS + non-standard integer port
$_SERVER['SERVER_PORT'] = 3030;
$this->assertEquals(HTTP::getServerPort(), ':3030');
// Test HTTPS + standard port
$_SERVER['SERVER_PORT'] = '443';
$this->assertEquals(HTTP::getServerPort(), '');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment