This commit is contained in:
Ryan P Kilby 2015-05-29 12:02:15 +00:00
commit b5dd6a7232
2 changed files with 8 additions and 3 deletions

View File

@ -379,11 +379,14 @@ class Request(object):
return return
# At this point we're committed to parsing the request as form data. # At this point we're committed to parsing the request as form data.
self._data = self._request.POST self._data, self._files = self._parse()
self._files = self._request.FILES
self._full_data = self._data.copy() self._full_data = self._data.copy()
self._full_data.update(self._files) 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. # Method overloading - change the method and remove the param from the content.
if ( if (
self._METHOD_PARAM and self._METHOD_PARAM and

View File

@ -58,6 +58,7 @@ class TestMethodOverloading(TestCase):
reserved form field reserved form field
""" """
request = Request(factory.post('/', {api_settings.FORM_METHOD_OVERRIDE: 'DELETE'})) request = Request(factory.post('/', {api_settings.FORM_METHOD_OVERRIDE: 'DELETE'}))
request.parsers = (MultiPartParser(), )
self.assertEqual(request.method, 'DELETE') self.assertEqual(request.method, 'DELETE')
def test_x_http_method_override_header(self): def test_x_http_method_override_header(self):
@ -66,6 +67,7 @@ class TestMethodOverloading(TestCase):
the X-HTTP-Method-Override header. the X-HTTP-Method-Override header.
""" """
request = Request(factory.post('/', {'foo': 'bar'}, HTTP_X_HTTP_METHOD_OVERRIDE='DELETE')) request = Request(factory.post('/', {'foo': 'bar'}, HTTP_X_HTTP_METHOD_OVERRIDE='DELETE'))
request.parsers = (MultiPartParser(), )
self.assertEqual(request.method, 'DELETE') self.assertEqual(request.method, 'DELETE')
request = Request(factory.get('/', {'foo': 'bar'}, HTTP_X_HTTP_METHOD_OVERRIDE='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 api_settings.FORM_CONTENTTYPE_OVERRIDE: content_type
} }
request = Request(factory.post('/', form_data)) request = Request(factory.post('/', form_data))
request.parsers = (JSONParser(), ) request.parsers = (JSONParser(), MultiPartParser(), )
self.assertEqual(request.DATA, json_data) self.assertEqual(request.DATA, json_data)
def test_form_POST_unicode(self): def test_form_POST_unicode(self):