diff --git a/Dispatcher/Dispatcher.php b/Dispatcher/Dispatcher.php index a38f5f81c..7866565fa 100644 --- a/Dispatcher/Dispatcher.php +++ b/Dispatcher/Dispatcher.php @@ -55,7 +55,7 @@ final class Dispatcher * * @since 1.0.0 */ - public function __construct(ApplicationAbstract $app) + public function __construct(ApplicationAbstract $app = null) { $this->app = $app; } diff --git a/Uri/Http.php b/Uri/Http.php index bdc0006ac..61619e171 100644 --- a/Uri/Http.php +++ b/Uri/Http.php @@ -187,7 +187,10 @@ final class Http implements UriInterface public static function getCurrent() : string { /** @noinspection PhpUndefinedConstantInspection */ - return 'http://' . ($_SERVER['HTTP_HOST'] ?? '') . ($_SERVER['REQUEST_URI'] ?? ''); + return ((!empty($_SERVER['HTTPS'] ?? '') && ($_SERVER['HTTPS'] ?? '') !== 'off') + || (($_SERVER['HTTP_X_FORWARDED_PROTO'] ?? '') === 'https') + || (($_SERVER['HTTP_X_FORWARDED_SSL'] ?? '') === 'on') ? 'https' : 'http') + . '://' . ($_SERVER['HTTP_HOST'] ?? ''). ($_SERVER['REQUEST_URI'] ?? ''); } /** diff --git a/Uri/UriFactory.php b/Uri/UriFactory.php index 8797b2266..465e11d19 100644 --- a/Uri/UriFactory.php +++ b/Uri/UriFactory.php @@ -116,6 +116,7 @@ final class UriFactory { self::setQuery('/scheme', $uri->getScheme()); self::setQuery('/host', $uri->getHost()); + self::setQuery('/port', (string) $uri->getPort()); self::setQuery('/base', \rtrim($uri->getBase(), '/')); self::setQuery('/rootPath', $uri->getRootPath()); self::setQuery('?', $uri->getQuery());