Issue 1745722: please add wsgi to SimpleXMLRPCServer (original) (raw)
There should be a simple wsgi xmlrpc application and in fact it is not difficult. You could for instance take this one and append it to SimpleXMLRPCServer.py.
class WSGIXMLRPCRequestHandler(SimpleXMLRPCDispatcher): def init(self, allow_none=False, encoding=None): SimpleXMLRPCDispatcher.init(self, allow_none, encoding) def call(self, environ, start_response): """WSGI interface""" if environ["REQUEST_METHOD"] != "POST": status = "400 Bad request" headers = [("Content-type", "text/html")] data = "400 Bad request
400 Bad request
" headers.append(("Content-length", str(len(data)))) start_response(status, headers) if environ["REQUEST_METHOD"] == "HEAD": return [] return [data] l = int(environ["CONTENT_LENGTH"]) request = environ["wsgi.input"].read(l) response = self._marshaled_dispatch(request) headers = [("Content-type", "text/xml")] headers.append(("Content-length", str(len(response)))) start_response("200 OK", headers) return [response]I've had a pep8-ification of this patch sitting on my disk for a while. Uploading it here so it doesn't get lost. It feels like there is a lot of redundancy now in the docs. But, it also seems to make sense to provide a wsgi version of this. So I'm inclined to commit it, but would appreciate second opinions.