Skip to content

Commit

Permalink
Pick port defaults depending if the host was in HTTP_HOST or from the…
Browse files Browse the repository at this point in the history
… running server
  • Loading branch information
lornajane committed Aug 13, 2018
1 parent 0618c56 commit 1ee987a
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions Slim/Http/Uri.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,15 +173,17 @@ public static function createFromEnvironment(Environment $env)
$username = $env->get('PHP_AUTH_USER', '');
$password = $env->get('PHP_AUTH_PW', '');

// Authority: Host
// Authority: Host and Port
if ($env->has('HTTP_HOST')) {
$host = $env->get('HTTP_HOST');
// set a port default
$port = 80;
} else {
$host = $env->get('SERVER_NAME');
// set a port default
$port = (int)$env->get('SERVER_PORT', 80);
}

// Authority: Port
$port = (int)$env->get('SERVER_PORT', 80);
if (preg_match('/^(\[[a-fA-F0-9:.]+\])(:\d+)?\z/', $host, $matches)) {
$host = $matches[1];

Expand Down

0 comments on commit 1ee987a

Please sign in to comment.