Skip to content

Commit 58d77c1

Browse files
committed
always obey X-HTTP-METHOD-OVERRIDE header
required to support old flash/flex clients that need to do everything as GET requests (apparently to allow for any error handlings)
1 parent f92d8bd commit 58d77c1

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

rest_framework/request.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -279,10 +279,9 @@ def _load_method_and_content_type(self):
279279
if not _hasattr(self, '_method'):
280280
self._method = self._request.method
281281

282-
if self._method == 'POST':
283-
# Allow X-HTTP-METHOD-OVERRIDE header
284-
self._method = self.META.get('HTTP_X_HTTP_METHOD_OVERRIDE',
285-
self._method)
282+
# Allow X-HTTP-METHOD-OVERRIDE header
283+
self._method = self.META.get('HTTP_X_HTTP_METHOD_OVERRIDE',
284+
self._method)
286285

287286
def _load_stream(self):
288287
"""

rest_framework/tests/test_request.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ def test_x_http_method_override_header(self):
6666
request = Request(factory.post('/', {'foo': 'bar'}, HTTP_X_HTTP_METHOD_OVERRIDE='DELETE'))
6767
self.assertEqual(request.method, 'DELETE')
6868

69+
request = Request(factory.get('/', {'foo': 'bar'}, HTTP_X_HTTP_METHOD_OVERRIDE='DELETE'))
70+
self.assertEqual(request.method, 'DELETE')
71+
6972

7073
class TestContentParsing(TestCase):
7174
def test_standard_behaviour_determines_no_content_GET(self):

0 commit comments

Comments
 (0)