Add the HTTP Patch to the Content-Type check mechanism

Currently when a request is of type 'patch' it is ignored. This commit makes
sure that the Content-Type is checked when a patch request is provided.
This commit is contained in:
Richard Torenvliet 2016-05-18 14:54:52 +02:00
parent 8cd5a64c27
commit e31ce0d58f
2 changed files with 7 additions and 1 deletions

View file

@ -505,7 +505,12 @@ class RequestHandlerComponent extends Component {
* in the request content type will be returned. * in the request content type will be returned.
*/ */
public function requestedWith($type = null) { public function requestedWith($type = null) {
if (!$this->request->is('post') && !$this->request->is('put') && !$this->request->is('delete')) { if (
!$this->request->is('patch') &&
!$this->request->is('post') &&
!$this->request->is('put') &&
!$this->request->is('delete')
) {
return null; return null;
} }
if (is_array($type)) { if (is_array($type)) {

View file

@ -97,6 +97,7 @@ class CakeRequest implements ArrayAccess {
*/ */
protected $_detectors = array( protected $_detectors = array(
'get' => array('env' => 'REQUEST_METHOD', 'value' => 'GET'), 'get' => array('env' => 'REQUEST_METHOD', 'value' => 'GET'),
'patch' => array('env' => 'REQUEST_METHOD', 'value' => 'PATCH'),
'post' => array('env' => 'REQUEST_METHOD', 'value' => 'POST'), 'post' => array('env' => 'REQUEST_METHOD', 'value' => 'POST'),
'put' => array('env' => 'REQUEST_METHOD', 'value' => 'PUT'), 'put' => array('env' => 'REQUEST_METHOD', 'value' => 'PUT'),
'delete' => array('env' => 'REQUEST_METHOD', 'value' => 'DELETE'), 'delete' => array('env' => 'REQUEST_METHOD', 'value' => 'DELETE'),