Skip to content

Commit

Permalink
Add support for DELETE + form encoded data.
Browse files Browse the repository at this point in the history
Much like PUT, DELETE requests will automatically parse
form-urlencoded request bodies and set them as $this->data.
  • Loading branch information
markstory committed Jun 18, 2012
1 parent c5b19b6 commit 5467902
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/Cake/Network/CakeRequest.php
Expand Up @@ -163,7 +163,7 @@ public function __construct($url = null, $parseEnvironment = true) {
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);
Expand Down
1 change: 1 addition & 0 deletions lib/Cake/Test/Case/Network/CakeRequestTest.php
Expand Up @@ -268,6 +268,7 @@ public function testPutParsing() {
);
$this->assertEquals($expected, $request->data);

$_SERVER['REQUEST_METHOD'] = 'DELETE';
$data = array('data' => array(
'Article' => array('title'),
'Tag' => array('Tag' => array(1, 2))
Expand Down

0 comments on commit 5467902

Please sign in to comment.