From 58d77c11c36623d2fd647a96e6871cbb93e17907 Mon Sep 17 00:00:00 2001 From: Ross McFarland Date: Fri, 17 Jan 2014 08:14:05 -0800 Subject: [PATCH] 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) --- rest_framework/request.py | 7 +++---- rest_framework/tests/test_request.py | 3 +++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/rest_framework/request.py b/rest_framework/request.py index 977d4d965..a570dcae2 100644 --- a/rest_framework/request.py +++ b/rest_framework/request.py @@ -279,10 +279,9 @@ class Request(object): if not _hasattr(self, '_method'): self._method = self._request.method - if self._method == 'POST': - # Allow X-HTTP-METHOD-OVERRIDE header - self._method = self.META.get('HTTP_X_HTTP_METHOD_OVERRIDE', - self._method) + # Allow X-HTTP-METHOD-OVERRIDE header + self._method = self.META.get('HTTP_X_HTTP_METHOD_OVERRIDE', + self._method) def _load_stream(self): """ diff --git a/rest_framework/tests/test_request.py b/rest_framework/tests/test_request.py index 969d8024a..3929bcc25 100644 --- a/rest_framework/tests/test_request.py +++ b/rest_framework/tests/test_request.py @@ -66,6 +66,9 @@ class TestMethodOverloading(TestCase): request = Request(factory.post('/', {'foo': 'bar'}, HTTP_X_HTTP_METHOD_OVERRIDE='DELETE')) self.assertEqual(request.method, 'DELETE') + request = Request(factory.get('/', {'foo': 'bar'}, HTTP_X_HTTP_METHOD_OVERRIDE='DELETE')) + self.assertEqual(request.method, 'DELETE') + class TestContentParsing(TestCase): def test_standard_behaviour_determines_no_content_GET(self):