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):
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:
- Fix parse errors in the readline module when compiling without threads.
+Library
+-------
+
+- Bug #1296004: httplib.py: Limit maximal amount of data read from the
+ socket to avoid a MemoryError on Windows.
+
What's New in Python 2.4.2 final?
=================================