Django

Code

Changeset 4107

Show
Ignore:
Timestamp:
11/26/06 17:52:12 (2 years ago)
Author:
adrian
Message:

Fixed #3057 -- Improved wsgi backend to tolerate empty string in CONTENT_LENGTH. Thanks for the patch, Ivan Sagalaev

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/core/handlers/wsgi.py

    r4094 r4107  
    158158        except AttributeError: 
    159159            buf = StringIO() 
    160             # CONTENT_LENGTH might be absent if POST doesn't have content at all (lighttpd) 
    161             content_length = int(self.environ.get('CONTENT_LENGTH', 0)) 
     160            try: 
     161                # CONTENT_LENGTH might be absent if POST doesn't have content at all (lighttpd) 
     162                content_length = int(self.environ.get('CONTENT_LENGTH', 0)) 
     163            except ValueError: # if CONTENT_LENGTH was empty string or not an integer 
     164                content_length = 0 
    162165            safe_copyfileobj(self.environ['wsgi.input'], buf, size=content_length) 
    163166            self._raw_post_data = buf.getvalue()