Description

XMLRPC is broken for FastCGI engine, unknown cause. It is not the same as MoinMoinBugs/XmlRpcBroken, because the CGI appears to work.

Steps to reproduce

Try to do an XMLRPC request to a FastCGI engine, such as:

   1 import xmlrpclib
   2 # Replace URL with server running FastCGI
   3 url = "http://moinmoin.wikiwikiweb.de/FrontPage?action=xmlrpc2"
   4 server = xmlrpclib.ServerProxy(url, verbose=True)
   5 server.getPage("FrontPage")

Example

Doesn't work here. Need to find a public FastCGI wiki first...

The following error is returned:

xml.parsers.expat.ExpatError: no element found: line 1, column 0
  File "/usr/lib/python2.4/site-packages/MoinMoin/wikirpc.py", line 402, in proc
ess
    params, method = xmlrpclib.loads(data)

  File "/usr/lib/python2.4/xmlrpclib.py", line 1080, in loads
    p.close()

  File "/usr/lib/python2.4/xmlrpclib.py", line 530, in close
    self._parser.Parse("", 1) # end of data

The code is in wikirpc.py, process(), starting at line 400:

   1   try:
   2      data = self.request.read()
   3      params, method = xmlrpclib.loads(data)

data returns a Null or empty string.

Details

MoinMoin Version

1.5.4 [Revision release]

OS and Version

Gentoo, with GCC 3.3.6 (Gentoo 3.3.6, ssp-3.3.6-1.0, pie-8.7.8)

Python Version

2.4.3 (#2, Jun 29 2006, 02:46:39)

Server Setup

Apache with FastCGI, single

Workaround

Use a different engine. Works with regular CGI, unknown on other engines.

Discussion

This looks like it is the same bug - the body is read before the XMLRPC code can handle it.

diff -r dc1784a3e30f MoinMoin/support/thfcgi.py
--- a/MoinMoin/support/thfcgi.py        Mon Jul 10 13:16:00 2006 +0200
+++ b/MoinMoin/support/thfcgi.py        Wed Jul 19 22:14:47 2006 +0100
@@ -281,8 +281,13 @@ class Request:
         """Return a cgi FieldStorage constructed from the stdin and
         environ read from the server for this request."""
         self.stdin.reset()
-        return cgi.FieldStorage(fp=self.stdin, environ=self.env,
-                                keep_blank_values=1)
+        # cgi.FieldStorage will eat the input here...
+        r = cgi.FieldStorage(fp=self.stdin, environ=self.env,
+                             keep_blank_values=1)
+        # hence, we reset here so we can obtain
+        # the data again...
+        self.stdin.reset()
+        return r
 
     def _flush(self, stream):
         """Flush a stream of this request."""
@@ -478,6 +483,8 @@ class Request:
         
         if not rec.content:
             self.stdin_complete = 1
+            self.stdin.reset()
+            return
 
         self.stdin.write(rec.content)

-- JohannesBerg DateTime(2006-07-19T21:16:10Z)

Works for bug submitter too. My site is fast again! Thank Johannes! -- JohnWhitlock 2006-07-20 13:21:34

Plan


CategoryMoinMoinBugFixed

MoinMoin: MoinMoinBugs/XmlRpcBrokenForFastCgi (last edited 2007-10-29 19:08:25 by localhost)