diff --git a/tests/test_websockifyserver.py b/tests/test_websockifyserver.py index 4f46cb19..79d1b258 100644 --- a/tests/test_websockifyserver.py +++ b/tests/test_websockifyserver.py @@ -86,7 +86,7 @@ def test_normal_get_with_only_upgrade_returns_error(self, send_error): FakeSocket(b'GET /tmp.txt HTTP/1.1'), '127.0.0.1', server) handler.do_GET() - send_error.assert_called_with(405, ANY) + send_error.assert_called_with(405) @patch('websockify.websockifyserver.WebSockifyRequestHandler.send_error') def test_list_dir_with_file_only_returns_error(self, send_error): @@ -96,7 +96,7 @@ def test_list_dir_with_file_only_returns_error(self, send_error): handler.path = '/' handler.do_GET() - send_error.assert_called_with(404, ANY) + send_error.assert_called_with(404) class WebSockifyServerTestCase(unittest.TestCase): diff --git a/websockify/websocketproxy.py b/websockify/websocketproxy.py index 8cfcd402..9b4595b4 100644 --- a/websockify/websocketproxy.py +++ b/websockify/websocketproxy.py @@ -327,8 +327,11 @@ def __init__(self, RequestHandlerClass=ProxyRequestHandler, *args, **kwargs): self.target_port = sock.getsockname()[1] sock.close() + # Insert rebinder at the head of the (possibly empty) LD_PRELOAD pathlist + ld_preloads = filter(None, [ self.rebinder, os.environ.get("LD_PRELOAD", None) ]) + os.environ.update({ - "LD_PRELOAD": self.rebinder, + "LD_PRELOAD": os.pathsep.join(ld_preloads), "REBIND_OLD_PORT": str(kwargs['listen_port']), "REBIND_NEW_PORT": str(self.target_port)}) diff --git a/websockify/websockifyserver.py b/websockify/websockifyserver.py index 8b33b3aa..74f9f536 100644 --- a/websockify/websockifyserver.py +++ b/websockify/websockifyserver.py @@ -250,13 +250,13 @@ def do_GET(self): self.auth_connection() if self.only_upgrade: - self.send_error(405, "Method Not Allowed") + self.send_error(405) else: super().do_GET() def list_directory(self, path): if self.file_only: - self.send_error(404, "No such file") + self.send_error(404) else: return super().list_directory(path) @@ -277,7 +277,7 @@ def do_HEAD(self): self.auth_connection() if self.only_upgrade: - self.send_error(405, "Method Not Allowed") + self.send_error(405) else: super().do_HEAD()