xmlrpc client through proxy to https server
Gustavo Rahal
gustavo at grahal.net
Tue Aug 12 17:18:48 EDT 2008
Hi
I'm trying to build a xmlrpc client that uses a proxy to connect to
a xmlrpc server in https.
I've googled and came up with a code snippet that doesn't actually
work.
What is missing?
class ProxiedTransport(xmlrpclib.Transport):
def set_proxy(self, proxy):
self.proxy = proxy
def make_connection(self, host):
self.realhost = host
# i've also tried httplib.HTTPS, in this case I get
# "socket.sslerror: (1, 'error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol')"
h = httplib.HTTP(self.proxy)
#trivial setup for ssl socket
# proxy_connect='CONNECT %s:%s HTTP/1.1\r\n'%('ftp3.linux.ibm.com', '443')
# user_agent='User-Agent: python\r\n'
# proxy_pieces=proxy_connect+user_agent+'\r\n'
# proxy=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
# proxy.connect(('9.47.67.150', 3128))
# proxy.sendall(proxy_pieces)
# response=proxy.recv(8192)
# ssl = socket.ssl(proxy, None, None)
# sock = httplib.FakeSocket(proxy, ssl)
# h.sock = sock
return h
def send_request(self, connection, handler, request_body):
connection.putrequest("POST", 'https://%s%s' % (self.realhost, handler))
def send_host(self, connection, host):
connection.putheader('Host', self.realhost)
p = ProxiedTransport()
p.set_proxy('9.47.67.150:3128')
server = xmlrpclib.Server('https://ftp3.linux.ibm.com/rpc/index.php', transport=p)
print server.user.ingroup("username", "group")
-------------------
The Result:
xmlrpclib.ProtocolError: <ProtocolError for
ftp3.linux.ibm.com/rpc/index.php: 501 Not Implemented>
The method i'm calling is "implemented". If I try straight xmlrpc
connection through a machine that is not behind a firewall things work
fine.
Appreciate help
Thanks
Gustavo
More information about the Python-list
mailing list