summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Holovaty <adrian@holovaty.com>2006-11-26 23:52:12 +0000
committerAdrian Holovaty <adrian@holovaty.com>2006-11-26 23:52:12 +0000
commite71fb7c7f27f4ecdc96b00f59e2a70a389c350a3 (patch)
tree8f6fd1ae755bf1df71135f989b034227f43140c5
parent4a14f2e23350aaf33de7f830b644a47a06100a1b (diff)
Fixed #3057 -- Improved wsgi backend to tolerate empty string in CONTENT_LENGTH. Thanks for the patch, Ivan Sagalaev
git-svn-id: http://code.djangoproject.com/svn/django/trunk@4107 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/core/handlers/wsgi.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/django/core/handlers/wsgi.py b/django/core/handlers/wsgi.py
index 7dc1a4a5eb..73ac1ae0c8 100644
--- a/django/core/handlers/wsgi.py
+++ b/django/core/handlers/wsgi.py
@@ -157,8 +157,11 @@ class WSGIRequest(http.HttpRequest):
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()