From 402bf81444f4cadd94f838eeb5a66374ffcfd87a Mon Sep 17 00:00:00 2001 From: Pulkit Jalan Date: Tue, 20 Sep 2016 08:31:52 +0100 Subject: [PATCH] Allow internal requests via commands Currently internal requests can't be made from within a command. When `$this->getRootRequest()->root()` runs it returns `http://:` because it is not able to resolve a host from `$_SERVER` (have a look at `Symfony\Component\HttpFoundation\Request@getHost`). This will prevent that from getting prefixed and allow requests from the command line. --- src/Dispatcher.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Dispatcher.php b/src/Dispatcher.php index 29e11e514..aee347e1d 100644 --- a/src/Dispatcher.php +++ b/src/Dispatcher.php @@ -462,8 +462,9 @@ protected function createRequest($verb, $uri, $parameters) // If the URI does not have a scheme then we can assume that there it is not an // absolute URI, in this case we'll prefix the root requests path to the URI. - if (! parse_url($uri, PHP_URL_SCHEME)) { - $uri = rtrim($this->getRootRequest()->root(), '/').'/'.ltrim($uri, '/'); + $rootUrl = $this->getRootRequest()->root(); + if ((! parse_url($uri, PHP_URL_SCHEME)) && parse_url($rootUrl) !== false) { + $uri = rtrim($rootUrl, '/').'/'.ltrim($uri, '/'); } $request = InternalRequest::create(