Skip to content

Commit b7a24e2

Browse files
committed
[HttpFoundation] Add OTIONS and TRACE to the list of safe methods
1 parent b7ed32a commit b7a24e2

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 methodProvider
1918+
*/
1919+
public function testMethodSafe()
1920+
{
1921+
$request = new Request();
1922+
$request->setMethod(Request::METHOD_GET);
1923+
$this->assertTrue($request->isMethodSafe());
1924+
}
1925+
1926+
public function methodProvider()
1927+
{
1928+
return array(
1929+
array(Request::METHOD_HEAD, true),
1930+
array(Request::METHOD_GET, true),
1931+
array(Request::METHOD_POST, false),
1932+
array(Request::METHOD_PUT, false),
1933+
array(Request::METHOD_PATCH, false),
1934+
array(Request::METHOD_DELETE, false),
1935+
array(Request::METHOD_PURGE, false),
1936+
array(Request::METHOD_OPTIONS, true),
1937+
array(Request::METHOD_TRACE, true),
1938+
array(Request::METHOD_CONNECT, false),
1939+
);
1940+
}
19151941
}
19161942

19171943
class RequestContentProxy extends Request

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy