xmlrpc client through proxy to https server

G

Gustavo Rahal

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top