diff options
author | Narayan Desai <desai@mcs.anl.gov> | 2009-05-11 01:07:22 +0000 |
---|---|---|
committer | Narayan Desai <desai@mcs.anl.gov> | 2009-05-11 01:07:22 +0000 |
commit | ef5bd55c3095b59d52d5a5ad5cda032892284543 (patch) | |
tree | 87da5c67496498d6a6efefae2c226c344a580016 /src/lib | |
parent | d40ecac784b7570b4ee56a572a41350eddc89622 (diff) | |
download | bcfg2-ef5bd55c3095b59d52d5a5ad5cda032892284543.tar.gz bcfg2-ef5bd55c3095b59d52d5a5ad5cda032892284543.tar.bz2 bcfg2-ef5bd55c3095b59d52d5a5ad5cda032892284543.zip |
SSL: client side read based on server-provided content length (allows graceful ssl shutdowns to work, makes server portable 0.9.5.7-trunk)
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5215 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/Proxy.py | 39 | ||||
-rw-r--r-- | src/lib/SSLServer.py | 4 |
2 files changed, 40 insertions, 3 deletions
diff --git a/src/lib/Proxy.py b/src/lib/Proxy.py index 864756f49..de2941a3c 100644 --- a/src/lib/Proxy.py +++ b/src/lib/Proxy.py @@ -94,6 +94,45 @@ class XMLRPCTransport(xmlrpclib.Transport): https._setup(http) return https + def request(self, host, handler, request_body, verbose=0): + '''send request to server and return response''' + h = self.make_connection(host) + self.send_request(h, handler, request_body) + self.send_host(h, host) + self.send_user_agent(h) + self.send_content(h, request_body) + + errcode, errmsg, headers = h.getreply() + msglen = int(headers.dict['content-length']) + + if errcode != 200: + raise ProtocolError(host + handler, errcode, errmsg, headers) + + self.verbose = verbose + + return self._get_response(h.getfile(), msglen) + + def _get_response(self, fd, length): + # read response from input file/socket, and parse it + recvd = 0 + + p, u = self.getparser() + + while recvd < length: + rlen = min(length - recvd, 1024) + response = fd.read(rlen) + recvd += len(response) + if not response: + break + if self.verbose: + print "body:", repr(response), len(response) + p.feed(response) + + fd.close() + p.close() + + return u.close() + def ComponentProxy (url, user=None, password=None, key=None, cert=None, ca=None): """Constructs proxies to components. diff --git a/src/lib/SSLServer.py b/src/lib/SSLServer.py index c29f0233b..a3840f71f 100644 --- a/src/lib/SSLServer.py +++ b/src/lib/SSLServer.py @@ -191,9 +191,7 @@ class XMLRPCRequestHandler (SimpleXMLRPCServer.SimpleXMLRPCRequestHandler): self.wfile.flush() self.wfile.close() self.rfile.close() - #self.connection.unwrap() - self.connection.shutdown(1) - + self.connection.unwrap() class XMLRPCServer (SocketServer.ThreadingMixIn, SSLServer, XMLRPCDispatcher, object): |