[Medusa-dev] [Medusa bug and patch] XML-RPC replies silently truncated to 1024 characters

Stephane Bortzmeyer bortzmeyer@nic.fr
Tue, 17 Sep 2002 11:35:32 +0200


---------------------- multipart/mixed attachment
On Fri, Jul 26, 2002 at 11:45:54PM +0200,
 Klaus Alexander Seistrup <gtxrs-xml-rpc@gmane.org> wrote 
 a message of 50 lines which said:

> > Suddenly, it started producing not well-formed XML, crashing
> > clients, and I can see why, when running under a debugger: when
> > the response is longer than 1024 characters, it is silently
> > truncated.
> 
> I had a similar problem with Medusa a couple of months ago: I could
...
> I sent a bug report to A.M. Kuchling, but have yet to receive a reply.

Here is a patch which works for me. The bug is in http_server which
does not check that the default buffer size is sufficient for the
reply. I add a test script as well.



---------------------- multipart/mixed attachment
--- /home/stephane/tmp/medusa-0.5.2/http_server.py	Mon Mar 25 15:26:29 2002
+++ ./http_server.py	Sun Sep 15 21:40:59 2002
@@ -156,7 +156,7 @@
 
     def push (self, thing):
         if type(thing) == type(''):
-            self.outgoing.append(producers.simple_producer (thing))
+            self.outgoing.append(producers.simple_producer(thing,buffer_size=len(thing)))
         else:
             self.outgoing.append(thing)
 


---------------------- multipart/mixed attachment
#!/usr/bin/python

from xmlrpclib import Server
import sys

# The bug is in Medusa, produces.py; http_server uses simple_producer which limits to its buffer_size.
# Workaround: increase the buffer size
# Solution: change http_server to use the buffer size it needs.

# If num >= 900, Medusa truncates the reply and of course everything fails ("missing tag")
if len(sys.argv) <= 1:
    num = 8
else:
    num = int(sys.argv[1])

s=Server('http://localhost:8080/')
print s.echoStructTest('X'*num)

---------------------- multipart/mixed attachment--