By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,435 Members | 2,891 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,435 IT Pros & Developers. It's quick & easy.

xmlrpc client through proxy to https server

P: n/a
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_STR EAM)
# 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

Aug 12 '08 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.