Fixed #3496 -- Handle the case of missing (and hence '0') Content-Length header

in a POST to the wsgi handler. Based on a patch from Mikko Ohtamaa.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@6592 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Malcolm Tredinnick 2007-10-21 23:52:08 +00:00
parent 0ffeb3a42f
commit 375a6d78cb
1 changed files with 3 additions and 1 deletions

View File

@ -165,7 +165,9 @@ class WSGIRequest(http.HttpRequest):
content_length = int(self.environ.get('CONTENT_LENGTH', 0)) content_length = int(self.environ.get('CONTENT_LENGTH', 0))
except ValueError: # if CONTENT_LENGTH was empty string or not an integer except ValueError: # if CONTENT_LENGTH was empty string or not an integer
content_length = 0 content_length = 0
safe_copyfileobj(self.environ['wsgi.input'], buf, size=content_length) if content_length > 0:
safe_copyfileobj(self.environ['wsgi.input'], buf,
size=content_length)
self._raw_post_data = buf.getvalue() self._raw_post_data = buf.getvalue()
buf.close() buf.close()
return self._raw_post_data return self._raw_post_data