diff options
author | Andrew M. Kuchling <amk@amk.ca> | 2005-12-08 14:54:20 (GMT) |
---|---|---|
committer | Andrew M. Kuchling <amk@amk.ca> | 2005-12-08 14:54:20 (GMT) |
commit | 432be36056ca12f5265616f07d2f369d5878982d (patch) | |
tree | e088c7caba3b53584c9ed01ecaf70d6368aca2b5 | |
parent | ef1b50de6c6113bf47719634a22eabe3a2635ef8 (diff) | |
download | cpython-432be36056ca12f5265616f07d2f369d5878982d.zip cpython-432be36056ca12f5265616f07d2f369d5878982d.tar.gz cpython-432be36056ca12f5265616f07d2f369d5878982d.tar.bz2 |
[Bug #1349316] Show how to use XML-RPC through a proxy
-rw-r--r-- | Doc/lib/libxmlrpclib.tex | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/Doc/lib/libxmlrpclib.tex b/Doc/lib/libxmlrpclib.tex index 6354c45..0fb88c5 100644 --- a/Doc/lib/libxmlrpclib.tex +++ b/Doc/lib/libxmlrpclib.tex @@ -355,3 +355,30 @@ try: except Error, v: print "ERROR", v \end{verbatim} + +To access an XML-RPC server through a proxy, you need to define +a custom transport. The following example, +written by NoboNobo, % fill in original author's name if we ever learn it +shows how: + +% Example taken from http://lowlife.jp/nobonobo/wiki/xmlrpcwithproxy.html +\begin{verbatim} +import xmlrpclib, httplib + +class ProxiedTransport(xmlrpclib.Transport): + def set_proxy(self, proxy): + self.proxy = proxy + def make_connection(self, host): + self.realhost = host + h = httplib.HTTP(self.proxy) + return h + def send_request(self, connection, handler, request_body): + connection.putrequest("POST", 'http://%s%s' % (self.realhost, handler)) + def send_host(self, connection, host): + connection.putheader('Host', self.realhost) + +p = ProxiedTransport() +p.set_proxy('proxy-server:8080') +server = xmlrpclib.Server('http://time.xmlrpc.com/RPC2', transport=p) +print server.currentTime.getCurrentTime() +\end{verbatim} |