Skip to content

Commit

Permalink
Adding CakeRequest::method() to find the name of the HTTP method name…
Browse files Browse the repository at this point in the history
… used for the request. Test case added.
  • Loading branch information
markstory committed Aug 22, 2010
1 parent 4a8e44b commit 0ec0962
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
9 changes: 9 additions & 0 deletions cake/libs/cake_request.php
Expand Up @@ -552,6 +552,15 @@ public function header($name) {
return false;
}

/**
* Get the HTTP method used for this request.
*
* @return string The name of the HTTP method used.
*/
public function method() {
return env('REQUEST_METHOD');
}

/**
* Find out which content types the client accepts or check if they accept a
* particular type of content.
Expand Down
12 changes: 12 additions & 0 deletions cake/tests/cases/libs/cake_request.test.php
Expand Up @@ -500,6 +500,18 @@ function testIsHttpMethods() {
$this->assertFalse($request->is('delete'));
}

/**
* test the method() method.
*
* @return void
*/
function testMethod() {
$_SERVER['REQUEST_METHOD'] = 'delete';
$request = new CakeRequest('some/path');

$this->assertEquals('delete', $request->method());
}

/**
* test ajax, flash and friends
*
Expand Down

0 comments on commit 0ec0962

Please sign in to comment.