Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.5] Fix unsetting http query parameters when fetching request by HEAD #24076

Merged
merged 2 commits into from
May 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions src/Illuminate/Http/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand All @@ -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;
Expand Down Expand Up @@ -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()]
)));
}

Expand Down Expand Up @@ -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()
);
}

Expand Down
7 changes: 7 additions & 0 deletions tests/Http/HttpRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
Expand Down