Skip to content

Commit

Permalink
Fixed #14594 -- Corrected a problem introduced by r14394 whereby read…
Browse files Browse the repository at this point in the history
…ing 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
  • Loading branch information
freakboy3742 committed Nov 2, 2010
1 parent 1fc7c4a commit 32f650c
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion django/http/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,17 @@ def _get_raw_post_data(self):
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)
Expand Down

0 comments on commit 32f650c

Please sign in to comment.