maxcutler/python-wordpress-xmlrpc

transport for proxy

Opened this issue · 0 comments

Qunal commented

Issue #61 suggest using custom transport but I am unable to make it work. As per example I am using proxied transport as follows
`import http.client
from wordpress_xmlrpc.compat import xmlrpc_client
from wordpress_xmlrpc import Client, WordPressPost

class ProxiedTransport(xmlrpc.client.Transport):

def set_proxy(self, host, port=None, headers=None):
    self.proxy = host, port
    self.proxy_headers = headers

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('http://proxy.server', 3128)`

But I get the following error in
wp = Client(WPHOST, WPUSER, WPPWD,transport)

File "/usr/lib/python3.6/socket.py", line 745, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name or service not known

my code worksin an installaion with no proxy and where I use
wp = Client(WPHOST, WPUSER, WPPWD)

Any help. Any example of actual transport behind a proxy and if I am importing the correct python modules