Ticket #3496: wsgi_patch2.diff

File wsgi_patch2.diff, 1.2 KB (added by cephelo@…, 8 years ago)

Patch that applies cleanly against trunk

  • django/core/handlers/wsgi.py

     
    160160            try:
    161161                # CONTENT_LENGTH might be absent if POST doesn't have content at all (lighttpd)
    162162                content_length = int(self.environ.get('CONTENT_LENGTH', 0))
     163                has_content_length = True
    163164            except ValueError: # if CONTENT_LENGTH was empty string or not an integer
    164165                content_length = 0
    165             safe_copyfileobj(self.environ['wsgi.input'], buf, size=content_length)
    166             self._raw_post_data = buf.getvalue()
     166                has_content_length = False
     167
     168            if has_content_length and content_length == 0:
     169                # Empty HTML forms do post a content length, but with a length of 0.
     170                # Socket read doesn't return with a size of 0. See #3496.
     171                pass
     172            else:
     173                safe_copyfileobj(self.environ['wsgi.input'], buf, size=content_length)
     174
     175            self._raw_post_data = buf.getvalue()
    167176            buf.close()
    168177            return self._raw_post_data
    169178
Back to Top