Ticket #2613: wsgi.py.diff
File wsgi.py.diff, 1.1 KB (added by , 18 years ago) |
---|
-
wsgi.py
50 50 505: 'HTTP VERSION NOT SUPPORTED', 51 51 } 52 52 53 try: 54 from cStringIO import StringIO 55 except ImportError: 56 from StringIO import StringIO 53 57 class WSGIRequest(http.HttpRequest): 54 58 def __init__(self, environ): 55 59 self.environ = environ … … 119 123 try: 120 124 return self._raw_post_data 121 125 except AttributeError: 122 self._raw_post_data = self.environ['wsgi.input'].read(int(self.environ["CONTENT_LENGTH"])) 126 mem = StringIO() 127 input = self.environ['wsgi.input'] 128 content_length = int(self.environ["CONTENT_LENGTH"]) 129 chunksize = 65536 # 64KB 130 while 1: 131 remain = content_length - mem.tell() 132 if remain <= 0: break 133 chunk = input.read(min(chunksize, remain)) 134 if not chunk: break 135 mem.write(chunk) 136 self._raw_post_data = mem.getvalue() 137 mem.close() 123 138 return self._raw_post_data 124 139 125 140 GET = property(_get_get, _set_get)