[Python-checkins] python/dist/src/Lib httplib.py, 1.94.2.1, 1.94.2.2

birkenfeld@users.sourceforge.net birkenfeld at users.sourceforge.net
Thu Sep 29 22:16:16 CEST 2005


Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7067/Lib
Modified Files:
 Tag: release24-maint
	httplib.py 
Log Message:
backport bug [ 1296004 ] MemoryError in httplib
Index: httplib.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/httplib.py,v
retrieving revision 1.94.2.1
retrieving revision 1.94.2.2
diff -u -d -r1.94.2.1 -r1.94.2.2
--- httplib.py	26 Jun 2005 22:06:56 -0000	1.94.2.1
+++ httplib.py	29 Sep 2005 20:16:12 -0000	1.94.2.2
@@ -153,6 +153,9 @@
 INSUFFICIENT_STORAGE = 507
 NOT_EXTENDED = 510
 
+# maximal amount of data to read at one time in _safe_read
+MAXAMOUNT = 1048576
+
 class HTTPMessage(mimetools.Message):
 
 def addheader(self, key, value):
@@ -541,14 +544,14 @@
 reading. If the bytes are truly not available (due to EOF), then the
 IncompleteRead exception can be used to detect the problem.
 """
- s = ''
+ s = []
 while amt > 0:
- chunk = self.fp.read(amt)
+ chunk = self.fp.read(min(amt, MAXAMOUNT))
 if not chunk:
 raise IncompleteRead(s)
- s += chunk
+ s.append(chunk)
 amt -= len(chunk)
- return s
+ return ''.join(s)
 
 def getheader(self, name, default=None):
 if self.msg is None:


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /