Skip to content

Commit

Permalink
[HttpFoundation] allow _method to be set in the query string (closes #…
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Jul 10, 2012
1 parent 9a2c617 commit 064ad62
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Symfony/Component/HttpFoundation/Request.php
Expand Up @@ -925,7 +925,7 @@ public function getMethod()
if (null === $this->method) {
$this->method = strtoupper($this->server->get('REQUEST_METHOD', 'GET'));
if ('POST' === $this->method) {
$this->method = strtoupper($this->headers->get('X-HTTP-METHOD-OVERRIDE', $this->request->get('_method', 'POST')));
$this->method = strtoupper($this->headers->get('X-HTTP-METHOD-OVERRIDE', $this->request->get('_method', $this->query->get('_method', 'POST'))));
}
}

Expand Down
5 changes: 5 additions & 0 deletions src/Symfony/Component/HttpFoundation/Tests/RequestTest.php
Expand Up @@ -620,6 +620,11 @@ public function testGetSetMethod()
$request->request->set('_method', 'purge');
$this->assertEquals('PURGE', $request->getMethod(), '->getMethod() returns the method from _method if defined and POST');

$request->setMethod('POST');
$request->request->remove('_method');
$request->query->set('_method', 'purge');
$this->assertEquals('PURGE', $request->getMethod(), '->getMethod() returns the method from _method if defined and POST');

$request->setMethod('POST');
$request->headers->set('X-HTTP-METHOD-OVERRIDE', 'delete');
$this->assertEquals('DELETE', $request->getMethod(), '->getMethod() returns the method from X-HTTP-Method-Override even though _method is set if defined and POST');
Expand Down

0 comments on commit 064ad62

Please sign in to comment.