8000 [HttpFoundation] Add OPTIONS and TRACE to the list of safe methods · symfony/symfony@1404607 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1404607

Browse files
dunglasfabpot
authored andcommitted
[HttpFoundation] Add OPTIONS and TRACE to the list of safe methods
1 parent b7ed32a commit 1404607

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

src/Symfony/Component/HttpFoundation/Request.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1470,7 +1470,7 @@ public function isMethod($method)
14701470
*/
14711471
public function isMethodSafe()
14721472
{
1473-
return in_array($this->getMethod(), array('GET', 'HEAD'));
1473+
return in_array($this->getMethod(), array('GET', 'HEAD', 'OPTIONS', 'TRACE'));
14741474
}
14751475

14761476
/**

src/Symfony/Component/HttpFoundation/Tests/RequestTest.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1912,6 +1912,32 @@ public function getLongHostNames()
19121912
array(str_repeat(':', 101)),
19131913
);
19141914
}
1915+
1916+
/**
1917+
* @dataProvider methodSafeProvider
1918+
*/
1919+
public function testMethodSafe($method, $safe)
1920+
{
1921+
$request = new Request();
1922+
$request->setMethod($method);
1923+
$this->assertEquals($safe, $request->isMethodSafe());
1924+
}
1925+
1926+
public function methodSafeProvider()
1927+
{
1928+
return array(
1929+
array('HEAD', true),
1930+
array('GET', true),
1931+
array('POST', false),
1932+
array('PUT', false),
1933+
array('PATCH', false),
1934+
array('DELETE', false),
1935+
array('PURGE', false),
1936+
array('OPTIONS', true),
1937+
array('TRACE', true),
1938+
array('CONNECT', false),
1939+
);
1940+
}
19151941
}
19161942

19171943
class RequestContentProxy extends Request

0 commit comments

Comments
 (0)
0