[HttpFoundation] Add OPTIONS and TRACE to the list of safe methods
This commit is contained in:
parent
b7ed32a36b
commit
1404607072
|
@ -1470,7 +1470,7 @@ class Request
|
|||
*/
|
||||
public function isMethodSafe()
|
||||
{
|
||||
return in_array($this->getMethod(), array('GET', 'HEAD'));
|
||||
return in_array($this->getMethod(), array('GET', 'HEAD', 'OPTIONS', 'TRACE'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1912,6 +1912,32 @@ class RequestTest extends \PHPUnit_Framework_TestCase
|
|||
array(str_repeat(':', 101)),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider methodSafeProvider
|
||||
*/
|
||||
public function testMethodSafe($method, $safe)
|
||||
{
|
||||
$request = new Request();
|
||||
$request->setMethod($method);
|
||||
$this->assertEquals($safe, $request->isMethodSafe());
|
||||
}
|
||||
|
||||
public function methodSafeProvider()
|
||||
{
|
||||
return array(
|
||||
array('HEAD', true),
|
||||
array('GET', true),
|
||||
array('POST', false),
|
||||
array('PUT', false),
|
||||
array('PATCH', false),
|
||||
array('DELETE', false),
|
||||
array('PURGE', false),
|
||||
array('OPTIONS', true),
|
||||
array('TRACE', true),
|
||||
array('CONNECT', false),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class RequestContentProxy extends Request
|
||||
|
|
Reference in New Issue