Skip to content

Commit

Permalink
Merge branch 'novnc:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
shiomax authored Dec 5, 2022
2 parents 494ddaf + d2affc7 commit ce29070
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
4 changes: 2 additions & 2 deletions tests/test_websockifyserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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):
Expand Down
5 changes: 4 additions & 1 deletion websockify/websocketproxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)})

Expand Down
6 changes: 3 additions & 3 deletions websockify/websockifyserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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()

Expand Down

0 comments on commit ce29070

Please sign in to comment.