Fixing xmlrpclib

Ng Pheng Siong ngps at
Fri May 5 11:44:59 EDT 2000

According to 5ÛHH575-UAZWKVVP-7H2H48V3 <thomas at>:
> Trying out the xmlrpclib with my local zope-site. Read in the How-To
> by Amos, located at, that the pythonware "version"  of
> xmlrpclib needed some fixing,

Amos's tutorial talks about creating a BasicAuthTransport class
derived from xmlrpclib.Transport. Just stick his code at the
end of

Alternatively, you can patch xmlrpclib.Transport directly:

---	Fri May  5 23:34:08 2000
+++	Fri May  5 23:36:16 2000
@@ -555,18 +555,25 @@
     def request(self, host, handler, request_body):
         # issue XML-RPC request
+        user_passwd, host_port = urllib.splituser(host)
+        _host, _port = urllib.splitport(host_port)
         import httplib
-        h = httplib.HTTP(host)
+        h = httplib.HTTP(_host, int(_port))
         h.putrequest("POST", handler)
         # required by HTTP/1.1
-        h.putheader("Host", host)
+        h.putheader("Host", _host)
         # required by XML-RPC
         h.putheader("User-Agent", self.user_agent)
         h.putheader("Content-Type", "text/xml")
         h.putheader("Content-Length", str(len(request_body)))
+        # Authorisation.
+        if user_passwd is not None:
+            auth=string.strip(base64.encodestring(user_passwd))
+            h.putheader('Authorization', 'Basic %s' % auth)

FWIW, I have also a patch to let xmlrpclib talk through
a http proxy. Let me know if you want it.

FWIW2, M2Crypto comes with, which extends 
xmlrpclib to work over https. 


Ng Pheng Siong <ngps at> *

More information about the Python-list mailing list