mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-07 22:04:48 +03:00
Merge 45203d20e6
into ecb3ba5e1f
This commit is contained in:
commit
b5dd6a7232
|
@ -379,11 +379,14 @@ class Request(object):
|
|||
return
|
||||
|
||||
# At this point we're committed to parsing the request as form data.
|
||||
self._data = self._request.POST
|
||||
self._files = self._request.FILES
|
||||
self._data, self._files = self._parse()
|
||||
self._full_data = self._data.copy()
|
||||
self._full_data.update(self._files)
|
||||
|
||||
# Point the underlying request data to our parsed data for backwards compatibility.
|
||||
self._request._post = self._data
|
||||
self._request._files = self._files
|
||||
|
||||
# Method overloading - change the method and remove the param from the content.
|
||||
if (
|
||||
self._METHOD_PARAM and
|
||||
|
|
|
@ -58,6 +58,7 @@ class TestMethodOverloading(TestCase):
|
|||
reserved form field
|
||||
"""
|
||||
request = Request(factory.post('/', {api_settings.FORM_METHOD_OVERRIDE: 'DELETE'}))
|
||||
request.parsers = (MultiPartParser(), )
|
||||
self.assertEqual(request.method, 'DELETE')
|
||||
|
||||
def test_x_http_method_override_header(self):
|
||||
|
@ -66,6 +67,7 @@ class TestMethodOverloading(TestCase):
|
|||
the X-HTTP-Method-Override header.
|
||||
"""
|
||||
request = Request(factory.post('/', {'foo': 'bar'}, HTTP_X_HTTP_METHOD_OVERRIDE='DELETE'))
|
||||
request.parsers = (MultiPartParser(), )
|
||||
self.assertEqual(request.method, 'DELETE')
|
||||
|
||||
request = Request(factory.get('/', {'foo': 'bar'}, HTTP_X_HTTP_METHOD_OVERRIDE='DELETE'))
|
||||
|
@ -148,7 +150,7 @@ class TestContentParsing(TestCase):
|
|||
api_settings.FORM_CONTENTTYPE_OVERRIDE: content_type
|
||||
}
|
||||
request = Request(factory.post('/', form_data))
|
||||
request.parsers = (JSONParser(), )
|
||||
request.parsers = (JSONParser(), MultiPartParser(), )
|
||||
self.assertEqual(request.DATA, json_data)
|
||||
|
||||
def test_form_POST_unicode(self):
|
||||
|
|
Loading…
Reference in New Issue
Block a user