Changeset 3806
- Timestamp:
- 09/23/06 08:04:37 (2 years ago)
- Files:
-
- django/trunk/AUTHORS (modified) (1 diff)
- django/trunk/django/core/handlers/wsgi.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/AUTHORS
r3805 r3806 101 101 Stuart Langridge <http://www.kryogenix.org/> 102 102 Eugene Lazutkin <http://lazutkin.com/blog/> 103 Jeong-Min Lee104 103 Christopher Lenz <http://www.cmlenz.net/> 105 104 limodou django/trunk/django/core/handlers/wsgi.py
r3805 r3806 5 5 from django import http 6 6 from pprint import pformat 7 from shutil import copyfileobj8 try:9 from cStringIO import StringIO10 except ImportError:11 from StringIO import StringIO12 7 13 8 # See http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html … … 55 50 505: 'HTTP VERSION NOT SUPPORTED', 56 51 } 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 of62 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 break70 fdst.write(buf)71 size -= len(buf)72 52 73 53 class WSGIRequest(http.HttpRequest): … … 140 120 return self._raw_post_data 141 121 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"])) 147 123 return self._raw_post_data 148 124
