Add support for DELETE + form encoded data.

Much like PUT, DELETE requests will automatically parse
form-urlencoded request bodies and set them as $this->data.
This commit is contained in:
mark_story 2012-06-17 20:03:45 -04:00
parent c5b19b658a
commit 54679023f9
2 changed files with 2 additions and 1 deletions

View file

@ -163,7 +163,7 @@ class CakeRequest implements ArrayAccess {
protected function _processPost() {
if ($_POST) {
$this->data = $_POST;
} elseif ($this->is('put')) {
} elseif ($this->is('put') || $this->is('delete')) {
$this->data = $this->_readInput();
if (env('CONTENT_TYPE') === 'application/x-www-form-urlencoded') {
parse_str($this->data, $this->data);

View file

@ -268,6 +268,7 @@ class CakeRequestTest extends CakeTestCase {
);
$this->assertEquals($expected, $request->data);
$_SERVER['REQUEST_METHOD'] = 'DELETE';
$data = array('data' => array(
'Article' => array('title'),
'Tag' => array('Tag' => array(1, 2))