Home > other >  How, in the XMLRPC using HTTP proxy with password
How, in the XMLRPC using HTTP proxy with password

Time:09-27

Question:
Computer as the client wants to local area network (need, through a proxy server to access the network proxy server need user name and password) to access the Internet on a server in the XMLRPC service
Code, of the following is the official reference documentation. The problem is to use HTTP client. The HTTPConnection connect need to account the proxy server (), how to set up a user name and password?
 
Import. HTTP client
The import XMLRPC. Client
The class ProxiedTransport (XMLRPC. Client. Transport) :
Def set_proxy (self, host, port=None, headers=None) :
The self. The proxy=host, port
Self. Proxy_headers=headers

Def make_connection (self, the host) :
Connection.=HTTP client. HTTPConnection (* the self in the proxy)
Connection. Set_tunnel (host, headers=self. Proxy_headers)
The self _connection=host, connection
The 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))