Django

Code

Changeset 3806

Show
Ignore:
Timestamp:
09/23/06 08:04:37 (2 years ago)
Author:
mtredinnick
Message:

Reverting r3805 whilst I track down a potential problem with it.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/AUTHORS

    r3805 r3806  
    101101    Stuart Langridge <http://www.kryogenix.org/> 
    102102    Eugene Lazutkin <http://lazutkin.com/blog/> 
    103     Jeong-Min Lee 
    104103    Christopher Lenz <http://www.cmlenz.net/> 
    105104    limodou 
  • django/trunk/django/core/handlers/wsgi.py

    r3805 r3806  
    55from django import http 
    66from pprint import pformat 
    7 from shutil import copyfileobj 
    8 try: 
    9     from cStringIO import StringIO 
    10 except ImportError: 
    11     from StringIO import StringIO 
    127 
    138# See http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html 
     
    5550    505: 'HTTP VERSION NOT SUPPORTED', 
    5651} 
    57  
    58 def safe_copyfileobj(fsrc, fdst, length=16*1024, size=0): 
    59     """ 
    60     A version of shutil.copyfileobj that will not read more than 'size' bytes. 
    61     This makes it safe from clients sending more than CONTENT_LENGTH bytes of 
    62     data in the body. 
    63     """ 
    64     if not size: 
    65         return copyfileobj(fsrc, fdst, length) 
    66     while size > 0: 
    67         buf = fsrc.read(min(length, remain)) 
    68         if not buf: 
    69             break 
    70         fdst.write(buf) 
    71         size -= len(buf) 
    7252 
    7353class WSGIRequest(http.HttpRequest): 
     
    140120            return self._raw_post_data 
    141121        except AttributeError: 
    142             buf = StringIO() 
    143             content_length = int(self.environ['CONTENT_LENGTH']) 
    144             safe_copyfileobj(self.environ['wsgi.input'], buf, size=content_length) 
    145             self._raw_post_data = buf.getvalue() 
    146             buf.close() 
     122            self._raw_post_data = self.environ['wsgi.input'].read(int(self.environ["CONTENT_LENGTH"])) 
    147123            return self._raw_post_data 
    148124