Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed #3057 -- Improved wsgi backend to tolerate empty string in CONT…

…ENT_LENGTH. Thanks for the patch, Ivan Sagalaev

git-svn-id: http://code.djangoproject.com/svn/django/trunk@4107 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit e71fb7c7f27f4ecdc96b00f59e2a70a389c350a3 1 parent 4a14f2e
@adrianholovaty adrianholovaty authored
Showing with 5 additions and 2 deletions.
  1. +5 −2 django/core/handlers/wsgi.py
View
7 django/core/handlers/wsgi.py
@@ -157,8 +157,11 @@ def _get_raw_post_data(self):
return self._raw_post_data
except AttributeError:
buf = StringIO()
- # CONTENT_LENGTH might be absent if POST doesn't have content at all (lighttpd)
- content_length = int(self.environ.get('CONTENT_LENGTH', 0))
+ try:
+ # CONTENT_LENGTH might be absent if POST doesn't have content at all (lighttpd)
+ content_length = int(self.environ.get('CONTENT_LENGTH', 0))
+ except ValueError: # if CONTENT_LENGTH was empty string or not an integer
+ content_length = 0
safe_copyfileobj(self.environ['wsgi.input'], buf, size=content_length)
self._raw_post_data = buf.getvalue()
buf.close()

0 comments on commit e71fb7c

Please sign in to comment.
Something went wrong with that request. Please try again.