mirror of
https://github.com/python/cpython.git
synced 2025-08-30 13:38:43 +00:00
[Bug #792570] Under Windows, socket.read() seems to run into trouble when
asked to read tens of megabytes of data. On my Mac, it hits MemoryErrors when reading around 15Mb in one chunk. The fix is to read the body in several parts, not as one big piece. It would be nice to fix the underlying socket.read() problem, too. 2.4 bugfix candidate.
This commit is contained in:
parent
3a97605500
commit
e63fde72f3
2 changed files with 16 additions and 2 deletions
|
@ -422,8 +422,19 @@ class SimpleXMLRPCRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# get arguments
|
# Get arguments by reading body of request.
|
||||||
data = self.rfile.read(int(self.headers["content-length"]))
|
# We read this in chunks to avoid straining
|
||||||
|
# socket.read(); around the 10 or 15Mb mark, some platforms
|
||||||
|
# begin to have problems (bug #792570).
|
||||||
|
max_chunk_size = 10*1024*1024
|
||||||
|
size_remaining = int(self.headers["content-length"])
|
||||||
|
L = []
|
||||||
|
while size_remaining:
|
||||||
|
chunk_size = min(size_remaining, max_chunk_size)
|
||||||
|
L.append(self.rfile.read(chunk_size))
|
||||||
|
size_remaining -= len(L[-1])
|
||||||
|
data = ''.join(L)
|
||||||
|
|
||||||
# In previous versions of SimpleXMLRPCServer, _dispatch
|
# In previous versions of SimpleXMLRPCServer, _dispatch
|
||||||
# could be overridden in this class, instead of in
|
# could be overridden in this class, instead of in
|
||||||
# SimpleXMLRPCDispatcher. To maintain backwards compatibility,
|
# SimpleXMLRPCDispatcher. To maintain backwards compatibility,
|
||||||
|
|
|
@ -451,6 +451,9 @@ Library
|
||||||
- Bug #1222790: in SimpleXMLRPCServer, set the reuse-address and close-on-exec
|
- Bug #1222790: in SimpleXMLRPCServer, set the reuse-address and close-on-exec
|
||||||
flags on the HTTP listening socket.
|
flags on the HTTP listening socket.
|
||||||
|
|
||||||
|
- Bug #792570: SimpleXMLRPCServer had problems if the request grew too large.
|
||||||
|
Fixed by reading the HTTP body in chunks instead of one big socket.read().
|
||||||
|
|
||||||
- Bug #1110478: Revert os.environ.update to do putenv again.
|
- Bug #1110478: Revert os.environ.update to do putenv again.
|
||||||
|
|
||||||
- Bug #1103844: fix distutils.install.dump_dirs() with negated options.
|
- Bug #1103844: fix distutils.install.dump_dirs() with negated options.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue