mirror of
https://github.com/python/cpython.git
synced 2025-09-27 10:50:04 +00:00
Fix errors in XML-RPC client example code
* http.client.HTTP (does not exist in Python 3) → HTTPConnection * Server (deprecated) → ServerProxy * Transport.send_request() grew a new “debug” parameter in Python 3 (revision a528f7f8f97a)
This commit is contained in:
parent
0334c3c735
commit
1c5e715d8f
1 changed files with 4 additions and 4 deletions
|
@ -541,7 +541,7 @@ Example of Client Usage
|
||||||
except Error as v:
|
except Error as v:
|
||||||
print("ERROR", v)
|
print("ERROR", v)
|
||||||
|
|
||||||
To access an XML-RPC server through a proxy, you need to define a custom
|
To access an XML-RPC server through a HTTP proxy, you need to define a custom
|
||||||
transport. The following example shows how:
|
transport. The following example shows how:
|
||||||
|
|
||||||
.. Example taken from http://lowlife.jp/nobonobo/wiki/xmlrpcwithproxy.html
|
.. Example taken from http://lowlife.jp/nobonobo/wiki/xmlrpcwithproxy.html
|
||||||
|
@ -555,16 +555,16 @@ transport. The following example shows how:
|
||||||
self.proxy = proxy
|
self.proxy = proxy
|
||||||
def make_connection(self, host):
|
def make_connection(self, host):
|
||||||
self.realhost = host
|
self.realhost = host
|
||||||
h = http.client.HTTP(self.proxy)
|
h = http.client.HTTPConnection(self.proxy)
|
||||||
return h
|
return h
|
||||||
def send_request(self, connection, handler, request_body):
|
def send_request(self, connection, handler, request_body, debug):
|
||||||
connection.putrequest("POST", 'http://%s%s' % (self.realhost, handler))
|
connection.putrequest("POST", 'http://%s%s' % (self.realhost, handler))
|
||||||
def send_host(self, connection, host):
|
def send_host(self, connection, host):
|
||||||
connection.putheader('Host', self.realhost)
|
connection.putheader('Host', self.realhost)
|
||||||
|
|
||||||
p = ProxiedTransport()
|
p = ProxiedTransport()
|
||||||
p.set_proxy('proxy-server:8080')
|
p.set_proxy('proxy-server:8080')
|
||||||
server = xmlrpc.client.Server('http://time.xmlrpc.com/RPC2', transport=p)
|
server = xmlrpc.client.ServerProxy('http://time.xmlrpc.com/RPC2', transport=p)
|
||||||
print(server.currentTime.getCurrentTime())
|
print(server.currentTime.getCurrentTime())
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue