However, the default client is missing many features, like handling proxies.
Using requests for the underlying connection allows for greater control of the
http request.

The xmlrpc client allows to change the underlying transport class by a custom
class. In order to use requests, we create a simple Transport class:

importrequestsimportxmlrpc.clientclassRequestsTransport(xmlrpc.client.Transport):defrequest(self,host,handler,data,verbose=False):# set the headers, including the user-agentheaders={"User-Agent":"my-user-agent","Content-Type":"text/xml","Accept-Encoding":"gzip"}url="https://%s%s"%(host,handler)try:response=Noneresponse=requests.post(url,data=data,headers=headers)response.raise_for_status()returnself.parse_response(response)exceptrequests.RequestExceptionase:ifresponseisNone:raisexmlrpc.client.ProtocolError(url,500,str(e),"")else:raisexmlrpc.client.ProtocolError(url,response.status_code,str(e),response.headers)defparse_response(self,resp):""" Parse the xmlrpc response. """p,u=self.getparser()p.feed(resp.text)p.close()returnu.close()

To use this Transport class, we should use:

proxy=xmlrpc.client.ServerProxy(uri,transport=RequestsTransport())

We can now use requests to:

use proxies

skip ssl verification (on a development server) or adding the right certificate chain