summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorLuke Plant <L.Plant.98@cantab.net>2011-03-28 16:11:40 +0000
committerLuke Plant <L.Plant.98@cantab.net>2011-03-28 16:11:40 +0000
commit8bb46d8b7c808bb366c7e15c46e5476e2b2b51a1 (patch)
tree9d9235a1701f8bb08fbbc815ec538632b149d43f /django
parent728770a5f9bbdcd4131f3a2552666aef54764aba (diff)
Fixed #15679 - regression in HttpRequest.POST and raw_post_data access.
Thanks to vkryachko for the report. This also fixes a slight inconsistency with raw_post_data after parsing of a multipart request, and adds a test for that. (Previously accessing raw_post_data would have returned the empty string rather than raising an Exception). git-svn-id: http://code.djangoproject.com/svn/django/trunk@15938 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django')
-rw-r--r--django/http/__init__.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/django/http/__init__.py b/django/http/__init__.py
index 62e327d926..b303f8bb6e 100644
--- a/django/http/__init__.py
+++ b/django/http/__init__.py
@@ -262,14 +262,18 @@ class HttpRequest(object):
if self.method != 'POST':
self._post, self._files = QueryDict('', encoding=self._encoding), MultiValueDict()
return
- if self._read_started:
+ if self._read_started and not hasattr(self, '_raw_post_data'):
self._mark_post_parse_error()
return
if self.META.get('CONTENT_TYPE', '').startswith('multipart'):
- self._raw_post_data = ''
+ if hasattr(self, '_raw_post_data'):
+ # Use already read data
+ data = StringIO(self._raw_post_data)
+ else:
+ data = self
try:
- self._post, self._files = self.parse_file_upload(self.META, self)
+ self._post, self._files = self.parse_file_upload(self.META, data)
except:
# An error occured while parsing POST data. Since when
# formatting the error the request handler might access