From 99c3e10d6e2cb14ed204c25055ce7b1b3c25a2f6 Mon Sep 17 00:00:00 2001 From: samhed Date: Tue, 19 Aug 2014 14:13:00 +0200 Subject: [PATCH 1/5] sync with commit from PR #347 in noVNC --- include/websock.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/include/websock.js b/include/websock.js index 01a24c3..0e4718a 100644 --- a/include/websock.js +++ b/include/websock.js @@ -262,7 +262,7 @@ function on(evt, handler) { eventHandlers[evt] = handler; } -function init(protocols) { +function init(protocols, ws_schema) { rQ = []; rQi = 0; sQ = []; @@ -277,12 +277,13 @@ function init(protocols) { ('set' in Uint8Array.prototype)) { bt = true; } - - // Check for full binary type support in WebSockets - // TODO: this sucks, the property should exist on the prototype - // but it does not. + // Check for full binary type support in WebSocket + // Inspired by: + // https://github.com/Modernizr/Modernizr/issues/370 + // https://github.com/Modernizr/Modernizr/blob/master/feature-detects/websockets/binary.js try { - if (bt && ('binaryType' in (new WebSocket("ws://localhost:17523")))) { + if (bt && ('binaryType' in WebSocket.prototype || + !!(new WebSocket(ws_schema + '://.').binaryType))) { Util.Info("Detected binaryType support in WebSockets"); wsbt = true; } @@ -325,7 +326,8 @@ function init(protocols) { } function open(uri, protocols) { - protocols = init(protocols); + var ws_schema = uri.match(/^([a-z]+):\/\//)[1]; + protocols = init(protocols, ws_schema); if (test_mode) { websocket = {}; From 4060d24de53c99285fb46e04264eb9d01683d932 Mon Sep 17 00:00:00 2001 From: Radek Podgorny Date: Thu, 2 Oct 2014 11:42:17 +0200 Subject: [PATCH 2/5] python3 compatibility fixes --- websockify/websocket.py | 2 +- websockify/websocketproxy.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/websockify/websocket.py b/websockify/websocket.py index d161f64..1b3dca9 100644 --- a/websockify/websocket.py +++ b/websockify/websocket.py @@ -388,7 +388,7 @@ class WebSocketRequestHandler(SimpleHTTPRequestHandler): def send_close(self, code=1000, reason=''): """ Send a WebSocket orderly close frame. """ - msg = pack(">H%ds" % len(reason), code, reason) + msg = pack(">H%ds" % len(reason), code, s2b(reason)) buf, h, t = self.encode_hybi(msg, opcode=0x08, base64=False) self.request.send(buf) diff --git a/websockify/websocketproxy.py b/websockify/websocketproxy.py index 7b3ec11..17d9451 100755 --- a/websockify/websocketproxy.py +++ b/websockify/websocketproxy.py @@ -90,7 +90,7 @@ Traffic Legend: # Extract the token parameter from url args = parse_qs(urlparse(path)[4]) # 4 is the query from url - if not args.has_key('token') or not len(args['token']): + if not 'token' in args or not len(args['token']): raise self.EClose("Token not present") token = args['token'][0].rstrip('\n') @@ -105,14 +105,14 @@ Traffic Legend: targets = {} for f in cfg_files: - for line in [l.strip() for l in file(f).readlines()]: + for line in [l.strip() for l in open(f).readlines()]: if line and not line.startswith('#'): ttoken, target = line.split(': ') targets[ttoken] = target.strip() self.vmsg("Target config: %s" % repr(targets)) - if targets.has_key(token): + if token in targets: return targets[token].split(':') else: raise self.EClose("Token '%s' not found" % token) From 7caa89f5a846f5379c06fc0f9e02972dc132408a Mon Sep 17 00:00:00 2001 From: ags131 Date: Fri, 16 May 2014 11:56:24 -0500 Subject: [PATCH 3/5] Fixed Package.json Added websockify.js to the files section, this fixes #90 and allows NPM to properly install --- other/js/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/other/js/package.json b/other/js/package.json index c1422b8..ef48920 100644 --- a/other/js/package.json +++ b/other/js/package.json @@ -8,7 +8,7 @@ "type": "git", "url": "git://github.com/kanaka/websockify.git" }, - "files": ["../../docs/LICENSE.LGPL-3"], + "files": ["../../docs/LICENSE.LGPL-3","websockify.js"], "bin": { "websockify": "./websockify.js" }, From fad9d962350a56819fd3f25c4e6733e16234e203 Mon Sep 17 00:00:00 2001 From: Solly Ross Date: Tue, 3 Feb 2015 16:51:01 -0500 Subject: [PATCH 4/5] Don't use implicit relative imports Implicit relative imports don't work in Python 3. This converts implicit relative imports into absolute imports (e.g. `import websocket` becomes `from websockify import websocket`). Fixes #154 --- websockify/__init__.py | 4 ++-- websockify/websocketproxy.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/websockify/__init__.py b/websockify/__init__.py index e8f2eaf..37a6f47 100644 --- a/websockify/__init__.py +++ b/websockify/__init__.py @@ -1,2 +1,2 @@ -from websocket import * -from websocketproxy import * +from websockify.websocket import * +from websockify.websocketproxy import * diff --git a/websockify/websocketproxy.py b/websockify/websocketproxy.py index 17d9451..ac9ed63 100755 --- a/websockify/websocketproxy.py +++ b/websockify/websocketproxy.py @@ -17,7 +17,7 @@ except: from SocketServer import ForkingMixIn try: from http.server import HTTPServer except: from BaseHTTPServer import HTTPServer from select import select -import websocket +from websockify import websocket try: from urllib.parse import parse_qs, urlparse except: From 49b4359f4bd270a8aa04947a68c04d454e7d0c89 Mon Sep 17 00:00:00 2001 From: Vaibhav Sagar Date: Sat, 6 Dec 2014 23:01:19 +0700 Subject: [PATCH 5/5] Add Python 3 trove classifiers. This makes display the status of this package correctly :). --- setup.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/setup.py b/setup.py index 0ea9cce..8a2f239 100644 --- a/setup.py +++ b/setup.py @@ -11,6 +11,12 @@ setup(name=name, long_description=long_description, classifiers=[ "Programming Language :: Python", + "Programming Language :: Python :: 2", + "Programming Language :: Python :: 2.6", + "Programming Language :: Python :: 2.7", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.3", + "Programming Language :: Python :: 3.4" ], data_files=[('share/websockify/include', ['include/util.js',