Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SimpleXMLRPCServer cannot handle large requests #39100

Closed
morissette mannequin opened this issue Aug 21, 2003 · 5 comments
Closed

SimpleXMLRPCServer cannot handle large requests #39100

morissette mannequin opened this issue Aug 21, 2003 · 5 comments
Assignees
Labels
stdlib Python modules in the Lib dir

Comments

@morissette
Copy link
Mannequin

morissette mannequin commented Aug 21, 2003

BPO 792570
Nosy @akuchling, @birkenfeld, @noplay

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = 'https://github.com/akuchling'
closed_at = <Date 2005-12-04.15:38:47.000>
created_at = <Date 2003-08-21.15:37:31.000>
labels = ['library']
title = 'SimpleXMLRPCServer cannot handle large requests'
updated_at = <Date 2005-12-04.15:38:47.000>
user = 'https://bugs.python.org/morissette'

bugs.python.org fields:

activity = <Date 2005-12-04.15:38:47.000>
actor = 'akuchling'
assignee = 'akuchling'
closed = True
closed_date = None
closer = None
components = ['Library (Lib)']
creation = <Date 2003-08-21.15:37:31.000>
creator = 'morissette'
dependencies = []
files = []
hgrepos = []
issue_num = 792570
keywords = []
message_count = 5.0
messages = ['17865', '17866', '17867', '17868', '17869']
nosy_count = 4.0
nosy_names = ['akuchling', 'georg.brandl', 'morissette', 'noplay']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = None
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue792570'
versions = ['Python 2.5']

@morissette
Copy link
Mannequin Author

morissette mannequin commented Aug 21, 2003

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

@morissette morissette mannequin closed this as completed Aug 21, 2003
@morissette morissette mannequin assigned akuchling Aug 21, 2003
@morissette morissette mannequin added the stdlib Python modules in the Lib dir label Aug 21, 2003
@morissette morissette mannequin closed this as completed Aug 21, 2003
@morissette morissette mannequin assigned akuchling Aug 21, 2003
@morissette morissette mannequin added the stdlib Python modules in the Lib dir label Aug 21, 2003
@birkenfeld
Copy link
Member

Logged In: YES
user_id=1188172

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

@noplay
Copy link
Mannequin

noplay mannequin commented Oct 21, 2005

Logged In: YES
user_id=446148

I have the same problem with Python2.4 with windows and
linux version.

If XML-RPC server reads to large buffer, it returns only a
part of the buffer.

@akuchling
Copy link
Member

Logged In: YES
user_id=11375

Why does SimpleXMLRPCServer need to be fixed if
socket.read() is choking? Shouldn't socket.read() be fixed
instead?

noplay: do you mean you're seeing this bug happen on Linux?
I don't use Windows, so being able to reproduce the problem
on Linux would be very useful.

@akuchling
Copy link
Member

Logged In: YES
user_id=11375

It turns out that on my Mac socket.read() runs into trouble
around 15Mb, so I could reproduce the problem. Fix committed
in rev 41586; it's the same principle as the suggested
change, but the code is rewritten for better scalability
(appending to a list instead of using a cStringIO). Thanks!

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir
Projects
None yet
Development

No branches or pull requests

2 participants