diff --git a/src/Concerns/RoutesRequests.php b/src/Concerns/RoutesRequests.php index 487edd6b..68d87494 100644 --- a/src/Concerns/RoutesRequests.php +++ b/src/Concerns/RoutesRequests.php @@ -547,15 +547,13 @@ public function dispatch($request = null) */ protected function parseIncomingRequest($request) { - if ($request) { - $this->instance(Request::class, $this->prepareRequest($request)); + if (! $request) { + $request = Request::capture(); + } - return [$request->getMethod(), $request->getPathInfo()]; - } else { - $this->instance(Request::class, Request::capture()); + $this->instance(Request::class, $this->prepareRequest($request)); - return [$this->getMethod(), $this->getPathInfo()]; - } + return [$request->getMethod(), $request->getPathInfo()]; } /** @@ -802,32 +800,6 @@ public function prepareResponse($response) return $response; } - /** - * Get the current HTTP request method. - * - * @return string - */ - protected function getMethod() - { - if (isset($_POST['_method'])) { - return strtoupper($_POST['_method']); - } else { - return $_SERVER['REQUEST_METHOD']; - } - } - - /** - * Get the current HTTP path info. - * - * @return string - */ - protected function getPathInfo() - { - $query = isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : ''; - - return '/'.trim(str_replace('?'.$query, '', $_SERVER['REQUEST_URI']), '/'); - } - /** * Get the raw routes for the application. * diff --git a/tests/FullApplicationTest.php b/tests/FullApplicationTest.php index e0be905b..332ef6be 100644 --- a/tests/FullApplicationTest.php +++ b/tests/FullApplicationTest.php @@ -57,44 +57,6 @@ public function testAddRouteMultipleMethodRequest() $this->assertEquals('Hello World', $response->getContent()); } - public function testRequestWithoutSymfonyClass() - { - $app = new Application; - - $app->get('/', function () { - return response('Hello World'); - }); - - $_SERVER['REQUEST_METHOD'] = 'GET'; - $_SERVER['REQUEST_URI'] = '/'; - - $response = $app->dispatch(); - - $this->assertEquals(200, $response->getStatusCode()); - $this->assertEquals('Hello World', $response->getContent()); - - unset($_SERVER['REQUEST_METHOD'], $_SERVER['REQUEST_URI']); - } - - public function testRequestWithoutSymfonyClassTrailingSlash() - { - $app = new Application; - - $app->get('/foo', function () { - return response('Hello World'); - }); - - $_SERVER['REQUEST_METHOD'] = 'GET'; - $_SERVER['REQUEST_URI'] = '/foo/'; - - $response = $app->dispatch(); - - $this->assertEquals(200, $response->getStatusCode()); - $this->assertEquals('Hello World', $response->getContent()); - - unset($_SERVER['REQUEST_METHOD'], $_SERVER['REQUEST_URI']); - } - public function testRequestWithParameters() { $app = new Application;