[ python-Bugs-792570 ] SimpleXMLRPCServer cannot handle large requests

SourceForge.net noreply at sourceforge.net
Wed Jun 1 14:26:24 CEST 2005


Bugs item #792570, was opened at 2003-08-21 17:37
Message generated for change (Comment added) made by birkenfeld
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=792570&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Marc-André Morissette (morissette)
Assigned to: Nobody/Anonymous (nobody)
Summary: SimpleXMLRPCServer cannot handle large requests

Initial Comment:
SimpleXMLRPCServer throws a WSAEINTR ioerror on 
large XML-RPC requests.

Under Windows, the socket.read() method cannot seem 
to handle large (tens of megabytes) reads (could be a 
Python specific problem). This means that very large 
XML-RPC requests can cause the exception.

Here is a tentative patch against 2.2.3 to fix the 
problem. It should be easy to port it to 2.3

---
 /cygdrive/c/Python22/Lib/SimpleXMLRPCServer.py      
2003-07-09 14:16:52.000000000 -0400
+++ /cygdrive/z/SimpleXMLRPCServer.py   2003-08-21 
11:01:19.000000000 -0400
@@ -73,6 +73,8 @@
 import SocketServer
 import BaseHTTPServer
 import sys
+import cStringIO

 class SimpleXMLRPCRequestHandler
(BaseHTTPServer.BaseHTTPRequestHandler):
     """Simple XML-RPC request handler class.
@@ -95,7 +97,14 @@

         try:
             # get arguments
-            data = self.rfile.read(int(self.headers["content-
length"]))
+            max_chunk_size = 10000000
+            content_length = int(self.headers["content-
length"])
+            buffer = cStringIO.StringIO()
+            for offset in range(0, content_length, 
max_chunk_size):
+                chunk_size = min(content_length - offset, 
max_chunk_size)
+                buffer.write(self.rfile.read(chunk_size))
+            data = buffer.getvalue()
+            buffer.close()
             params, method = xmlrpclib.loads(data)

             # generate response



----------------------------------------------------------------------

>Comment By: Reinhold Birkenfeld (birkenfeld)
Date: 2005-06-01 14:26

Message:
Logged In: YES 
user_id=1188172

Marc-Andre, can you still reproduce this with Python 2.4?

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=792570&group_id=5470


More information about the Python-bugs-list mailing list