[HttpFoundation] allow _method to be set in the query string (closes #4202)
This commit is contained in:
parent
9a2c61780b
commit
064ad6255c
@ -925,7 +925,7 @@ class Request
|
||||
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'))));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -620,6 +620,11 @@ class RequestTest extends \PHPUnit_Framework_TestCase
|
||||
$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');
|
||||
|
Reference in New Issue
Block a user