Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 500c2cd

Browse filesBrowse files
committed
bug #19321 [HttpFoundation] Add OPTIONS and TRACE to the list of safe methods (dunglas)
This PR was squashed before being merged into the 2.7 branch (closes #19321). Discussion ---------- [HttpFoundation] Add OPTIONS and TRACE to the list of safe methods | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | n/a | License | MIT | Doc PR | n/a According to [RFC 7231](https://tools.ietf.org/html/rfc7231#section-8.1.3) `OPTIONS` and `TRACE` are safe methods. Commits ------- 1404607 [HttpFoundation] Add OPTIONS and TRACE to the list of safe methods
2 parents 8b6d74e + 1404607 commit 500c2cd
Copy full SHA for 500c2cd

File tree

Expand file treeCollapse file tree

2 files changed

+27
-1
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+27
-1
lines changed

‎src/Symfony/Component/HttpFoundation/Request.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/Request.php
+1-1Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/Tests/RequestTest.php
+26Lines 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)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.