cpython: 60c5c77c0190 (original) (raw)
Mercurial > cpython
changeset 104412:60c5c77c0190 3.6
Issue #28389: Merge from 3.5 [#28389]
Berker Peksag berker.peksag@gmail.com | |
---|---|
date | Sun, 09 Oct 2016 18🔞55 +0300 |
parents | f8d84a3c9e86(current diff)94c9c314f5d9(diff) |
children | 5f9351bc317e 019c5c2f1239 |
files | Doc/library/xmlrpc.client.rst |
diffstat | 1 files changed, 15 insertions(+), 21 deletions(-)[+] [-] Doc/library/xmlrpc.client.rst 36 |
line wrap: on
line diff
--- a/Doc/library/xmlrpc.client.rst +++ b/Doc/library/xmlrpc.client.rst @@ -568,33 +568,27 @@ Example of Client Usage print("ERROR", v) To access an XML-RPC server through a HTTP proxy, you need to define a custom -transport. The following example shows how: - -.. Example taken from http://lowlife.jp/nobonobo/wiki/xmlrpcwithproxy.html[](#l1.9) +transport. The following example shows how:: -:: -
def set_proxy(self, proxy):[](#l1.19)
self.proxy = proxy[](#l1.20)
def set_proxy(self, host, port=None, headers=None):[](#l1.22)
self.proxy = host, port[](#l1.23)
self.proxy_headers = headers[](#l1.24)
def make_connection(self, host):
self.realhost = host[](#l1.27)
h = http.client.HTTPConnection(self.proxy)[](#l1.28)
return h[](#l1.29)
def send_request(self, connection, handler, request_body, debug):[](#l1.31)
connection.putrequest("POST", 'http://%s%s' % (self.realhost, handler))[](#l1.32)
connection = http.client.HTTPConnection(*self.proxy)[](#l1.33)
connection.set_tunnel(host, headers=self.proxy_headers)[](#l1.34)
self._connection = host, connection[](#l1.35)
return connection[](#l1.36)
def send_host(self, connection, host):[](#l1.38)
connection.putheader('Host', self.realhost)[](#l1.39)
- p = ProxiedTransport()
- p.set_proxy('proxy-server:8080')
- server = xmlrpc.client.ServerProxy('http://time.xmlrpc.com/RPC2', transport=p)
- print(server.currentTime.getCurrentTime())
- transport = ProxiedTransport()
- transport.set_proxy('proxy-server', 8080)
- server = xmlrpc.client.ServerProxy('http://betty.userland.com', transport=transport)
- print(server.examples.getStateName(41))