Code

Ticket #3057: 3057.2.diff

File 3057.2.diff, 903 bytes (added by Ivan Sagalaev <Maniac@…>, 7 years ago)

Fixing empty string in Content-Length

Line 
1Index: django/core/handlers/wsgi.py
2===================================================================
3--- django/core/handlers/wsgi.py        (revision 4094)
4+++ django/core/handlers/wsgi.py        (working copy)
5@@ -157,8 +157,11 @@
6             return self._raw_post_data
7         except AttributeError:
8             buf = StringIO()
9-            # CONTENT_LENGTH might be absent if POST doesn't have content at all (lighttpd)
10-            content_length = int(self.environ.get('CONTENT_LENGTH', 0))
11+            try:
12+              # CONTENT_LENGTH might be absent if POST doesn't have content at all (lighttpd)
13+              content_length = int(self.environ.get('CONTENT_LENGTH', 0))
14+            except ValueError:
15+              content_length = 0
16             safe_copyfileobj(self.environ['wsgi.input'], buf, size=content_length)
17             self._raw_post_data = buf.getvalue()
18             buf.close()