diff --git a/cake/libs/cake_request.php b/cake/libs/cake_request.php index 6a84f16e7..1b15c2239 100644 --- a/cake/libs/cake_request.php +++ b/cake/libs/cake_request.php @@ -552,6 +552,15 @@ class CakeRequest implements ArrayAccess { 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. diff --git a/cake/tests/cases/libs/cake_request.test.php b/cake/tests/cases/libs/cake_request.test.php index 3c51bc9b7..ff7107a56 100644 --- a/cake/tests/cases/libs/cake_request.test.php +++ b/cake/tests/cases/libs/cake_request.test.php @@ -500,6 +500,18 @@ class CakeRequestTestCase extends CakeTestCase { $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 *