Skip to content

Commit

Permalink
[HttpFoundation] Request::getRealMethod() now returns UPPERCASE
Browse files Browse the repository at this point in the history
  • Loading branch information
vicb committed Nov 30, 2012
1 parent 50a62da commit bad50ac
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Symfony/Component/HttpFoundation/Request.php
Expand Up @@ -1064,7 +1064,7 @@ public function getMethod()
*/
public function getRealMethod()
{
return $this->server->get('REQUEST_METHOD', 'GET');
return strtoupper($this->server->get('REQUEST_METHOD', 'GET'));
}

/**
Expand Down
15 changes: 11 additions & 4 deletions src/Symfony/Component/HttpFoundation/Tests/RequestTest.php
Expand Up @@ -770,6 +770,10 @@ public function provideOverloadedMethods()
array('PUT'),
array('DELETE'),
array('PATCH'),
array('put'),
array('delete'),
array('patch'),

);
}

Expand All @@ -778,6 +782,8 @@ public function provideOverloadedMethods()
*/
public function testCreateFromGlobals($method)
{
$normalizedMethod = strtoupper($method);

$_GET['foo1'] = 'bar1';
$_POST['foo2'] = 'bar2';
$_COOKIE['foo3'] = 'bar3';
Expand All @@ -796,18 +802,19 @@ public function testCreateFromGlobals($method)
$_SERVER['REQUEST_METHOD'] = $method;
$_SERVER['CONTENT_TYPE'] = 'application/x-www-form-urlencoded';
$request = RequestContentProxy::createFromGlobals();
$this->assertEquals($method, $request->getMethod());
$this->assertEquals($normalizedMethod, $request->getMethod());
$this->assertEquals('mycontent', $request->request->get('content'));

unset($_SERVER['REQUEST_METHOD'], $_SERVER['CONTENT_TYPE']);

$request = Request::createFromGlobals();
Request::createFromGlobals();
Request::enableHttpMethodParameterOverride();
$_POST['_method'] = $method;
$_POST['foo6'] = 'bar6';
$_SERVER['REQUEST_METHOD'] = 'POST';
$_SERVER['REQUEST_METHOD'] = 'PoSt';
$request = Request::createFromGlobals();
$this->assertEquals($method, $request->getMethod());
$this->assertEquals($normalizedMethod, $request->getMethod());
$this->assertEquals('POST', $request->getRealMethod());
$this->assertEquals('bar6', $request->request->get('foo6'));

unset($_POST['_method'], $_POST['foo6'], $_SERVER['REQUEST_METHOD']);
Expand Down

0 comments on commit bad50ac

Please sign in to comment.