Ticket #3496: wsgi_patch.diff

File wsgi_patch.diff, 1.2 KB (added by mikko@…, 18 years ago)

Fixes empty checkbox bug in WSGI handler

  • 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                has_content_length = False
     167           
     168            if has_content_length and content_length == 0:
     169                # A case when HTML form containing only empty checkboxes
     170                # is submitted. It POSTs zero length HTTP request.
     171                #
     172                # Socket read doesn't return if we pass size=0
     173                # forward this point and Django request handling hangs.
     174                pass
     175            else:                 
     176                safe_copyfileobj(self.environ['wsgi.input'], buf, size=content_length)
     177           
    166178            self._raw_post_data = buf.getvalue()
    167179            buf.close()
    168180            return self._raw_post_data
Back to Top