Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
cd0da312
Commit
cd0da312
authored
Oct 09, 2016
by
Berker Peksag
Browse files
Options
Browse Files
Download
Plain Diff
Issue #28389: Merge from 3.5
parents
8eaa29c9
ae70e48c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
22 deletions
+16
-22
Doc/library/xmlrpc.client.rst
Doc/library/xmlrpc.client.rst
+16
-22
No files found.
Doc/library/xmlrpc.client.rst
View file @
cd0da312
...
...
@@ -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:
transport. The following example shows how:
:
.. Example taken from http://lowlife.jp/nobonobo/wiki/xmlrpcwithproxy.html
::
import xmlrpc.client, http.client
import http.client
import xmlrpc.client
class ProxiedTransport(xmlrpc.client.Transport):
def set_proxy(self, proxy):
self.proxy = proxy
def make_connection(self, host):
self.realhost = host
h = http.client.HTTPConnection(self.proxy)
return h
def send_request(self, connection, handler, request_body, debug):
connection.putrequest("POST", 'http://%s%s' % (self.realhost, handler))
def set_proxy(self, host, port=None, headers=None):
self.proxy = host, port
self.proxy_headers = headers
def send_host(self, connection, host):
connection.putheader('Host', self.realhost)
p = ProxiedTransport()
p.set_proxy('proxy-server:8080')
server = xmlrpc.client.ServerProxy('http://time.xmlrpc.com/RPC2', transport=p)
print(server.currentTime.getCurrentTime())
def make_connection(self, host):
connection = http.client.HTTPConnection(*self.proxy)
connection.set_tunnel(host, headers=self.proxy_headers)
self._connection = host, connection
return connection
transport = ProxiedTransport()
transport.set_proxy('proxy-server', 8080)
server = xmlrpc.client.ServerProxy('http://betty.userland.com', transport=transport)
print(server.examples.getStateName(41))
Example of Client and Server Usage
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment