[TOOLS] Make sure to explicitly close the connection if we're using HTTP/1.0. This
authorkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Thu, 22 Jun 2006 14:10:48 +0000 (15:10 +0100)
committerkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Thu, 22 Jun 2006 14:10:48 +0000 (15:10 +0100)
shouldn't be needed but it appears to be necessary as the Python client
just does a wfile.read() instead of only reading the reported Content-Length.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
tools/python/xen/util/xmlrpclib2.py

index f48323cd87ef47fc49292a1c13e5129d4e6e9202..c4976abc2e15aa10ac1967dd40f9db09dd819e17 100644 (file)
@@ -58,8 +58,6 @@ class XMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
     #    propagate so that it shows up in the Xend debug logs
     # 2) we don't bother checking for a _dispatch function since we don't
     #    use one
-    # 3) we never shutdown the connection.  This appears to be a bug in
-    #    SimpleXMLRPCServer.py as it breaks HTTP Keep-Alive
     def do_POST(self):
         data = self.rfile.read(int(self.headers["content-length"]))
         rsp = self.server._marshaled_dispatch(data)
@@ -71,6 +69,8 @@ class XMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
 
         self.wfile.write(rsp)
         self.wfile.flush()
+        if self.close_connection == 1:
+            self.connection.shutdown(1)
 
 class HTTPUnixConnection(HTTPConnection):
     def connect(self):