From 67ae5fa80d7d9cd5f454936cc8764be35355ff7b Mon Sep 17 00:00:00 2001 From: Lynn Lin Date: Wed, 2 May 2018 17:08:38 +0800 Subject: [PATCH 1/2] fix request method to use $_GET variables when HEAD --- src/Illuminate/Http/Request.php | 2 +- tests/Http/HttpRequestTest.php | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Illuminate/Http/Request.php b/src/Illuminate/Http/Request.php index 6916063e3e73..d92e5a083aba 100644 --- a/src/Illuminate/Http/Request.php +++ b/src/Illuminate/Http/Request.php @@ -340,7 +340,7 @@ protected function getInputSource() return $this->json(); } - return $this->getRealMethod() == 'GET' ? $this->query : $this->request; + return in_array($this->getRealMethod(), ['GET', 'HEAD']) ? $this->query : $this->request; } /** diff --git a/tests/Http/HttpRequestTest.php b/tests/Http/HttpRequestTest.php index 540d7878a7df..455a2d6656c5 100644 --- a/tests/Http/HttpRequestTest.php +++ b/tests/Http/HttpRequestTest.php @@ -453,6 +453,13 @@ public function testReplaceMethod() $this->assertEquals('Dayle', $request->input('buddy')); } + public function testOffsetUnsetMethod() + { + $request = Request::create('/', 'HEAD', ['name' => 'Taylor']); + $request->offsetUnset('name'); + $this->assertNull($request->input('name')); + } + public function testHeaderMethod() { $request = Request::create('/', 'GET', [], [], [], ['HTTP_DO_THIS' => 'foo']); From 7a8b256397c62ad04537ceb06ab1208908b69a46 Mon Sep 17 00:00:00 2001 From: Lynn Lin Date: Wed, 2 May 2018 17:09:27 +0800 Subject: [PATCH 2/2] fix coding style of http request --- src/Illuminate/Http/Request.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/Illuminate/Http/Request.php b/src/Illuminate/Http/Request.php index d92e5a083aba..aa315f91a1ed 100644 --- a/src/Illuminate/Http/Request.php +++ b/src/Illuminate/Http/Request.php @@ -358,8 +358,12 @@ public static function createFromBase(SymfonyRequest $request) $content = $request->content; $request = (new static)->duplicate( - $request->query->all(), $request->request->all(), $request->attributes->all(), - $request->cookies->all(), $request->files->all(), $request->server->all() + $request->query->all(), + $request->request->all(), + $request->attributes->all(), + $request->cookies->all(), + $request->files->all(), + $request->server->all() ); $request->content = $content; @@ -472,7 +476,8 @@ public function fingerprint() } return sha1(implode('|', array_merge( - $route->methods(), [$route->getDomain(), $route->uri(), $this->ip()] + $route->methods(), + [$route->getDomain(), $route->uri(), $this->ip()] ))); } @@ -558,7 +563,8 @@ public function toArray() public function offsetExists($offset) { return array_key_exists( - $offset, $this->all() + $this->route()->parameters() + $offset, + $this->all() + $this->route()->parameters() ); }