diff --git a/src/xpra/net/websockets/handler.py b/src/xpra/net/websockets/handler.py index 91cc369cb2..bbc7ceceee 100644 --- a/src/xpra/net/websockets/handler.py +++ b/src/xpra/net/websockets/handler.py @@ -56,7 +56,6 @@ def handle_websocket(self): ): self.wfile.write(b"%s\r\n" % upgrade_string) self.wfile.flush() - self.wfile.close() self.new_websocket_client(self) def do_GET(self): @@ -64,8 +63,6 @@ def do_GET(self): if self.only_upgrade or upgrade_requested: if not upgrade_requested: self.send_error(403, "only websocket connections are allowed") - self.wfile.flush() - self.wfile.close() return try: self.handle_websocket() @@ -74,17 +71,17 @@ def do_GET(self): log.error("Error: cannot handle websocket upgrade:") log.error(" %s", e) self.send_error(403, "failed to handle websocket: %s" % e) - self.wfile.flush() - self.wfile.close() return - self.handle_request() + HTTPRequestHandler.do_GET(self) + + def do_HEAD(self): + if self.only_upgrade: + self.send_error(405, "Method Not Allowed") + return + HTTPRequestHandler.do_HEAD(self) def handle_request(self): if self.only_upgrade: self.send_error(405, "Method Not Allowed") - else: - content = self.send_head() - if content: - self.wfile.write(content) - self.wfile.flush() - self.wfile.close() + return + HTTPRequestHandler.handle_request(self) diff --git a/src/xpra/server/http_handler.py b/src/xpra/server/http_handler.py index 11bda04683..dd62470fdf 100644 --- a/src/xpra/server/http_handler.py +++ b/src/xpra/server/http_handler.py @@ -183,16 +183,9 @@ def handle_request(self): content = self.send_head() if content: self.wfile.write(content) - self.wfile.flush() - self.wfile.close() def do_HEAD(self): - if self.only_upgrade: - self.send_error(405, "Method Not Allowed") - else: - self.send_head() - self.wfile.flush() - self.wfile.close() + self.send_head() #code taken from MIT licensed code in GzipSimpleHTTPServer.py def send_head(self): @@ -206,8 +199,6 @@ def send_head(self): path = self.translate_path(self.path) if not path: self.send_error(404, "Path not found") - self.wfile.flush() - self.wfile.close() return None if os.path.isdir(path): if not path.endswith('/'):