summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRussell Keith-Magee <russell@keith-magee.com>2010-11-02 07:38:06 +0000
committerRussell Keith-Magee <russell@keith-magee.com>2010-11-02 07:38:06 +0000
commit32f650cfccec3a07e6c1fd18e58284101dc83a2d (patch)
treec59f4e8045fe60dded12bb11b998b806ecec1f08
parent1fc7c4aee44af3d5c55d3532aa8fb5b2d9102a62 (diff)
Fixed #14594 -- Corrected a problem introduced by r14394 whereby reading POST data when running a WSGI server under CherryPy would hang. Thanks to Mark Sundstrom for the report.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@14435 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/http/__init__.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/django/http/__init__.py b/django/http/__init__.py
index 2fa683dbbb..a585b3b6bb 100644
--- a/django/http/__init__.py
+++ b/django/http/__init__.py
@@ -140,7 +140,17 @@ class HttpRequest(object):
if not hasattr(self, '_raw_post_data'):
if self._read_started:
raise Exception("You cannot access raw_post_data after reading from request's data stream")
- self._raw_post_data = self.read()
+ try:
+ content_length = int(self.META.get('CONTENT_LENGTH', 0))
+ except (ValueError, TypeError):
+ # If CONTENT_LENGTH was empty string or not an integer, don't
+ # error out. We've also seen None passed in here (against all
+ # specs, but see ticket #8259), so we handle TypeError as well.
+ content_length = 0
+ if content_length:
+ self._raw_post_data = self.read()
+ else:
+ self._raw_post_data = self.read(int(content_length))
self._stream = StringIO(self._raw_post_data)
return self._raw_post_data
raw_post_data = property(_get_raw_post_data)