diff options
author | Chandler Abraham <cabraham@twitter.com> | 2015-04-11 11:35:15 -0700 |
---|---|---|
committer | Chandler Abraham <cabraham@twitter.com> | 2015-04-11 11:35:15 -0700 |
commit | 0edc04814e3affa71025938ac354707b9b4c481c (patch) | |
tree | 68858f9e13f9dc1e480f8329ed8adfd0221b4d18 /netlib/websockets/implementations.py | |
parent | e41e5cbfdd7b778e6f68e86658e95f9e413133cb (diff) | |
download | mitmproxy-0edc04814e3affa71025938ac354707b9b4c481c.tar.gz mitmproxy-0edc04814e3affa71025938ac354707b9b4c481c.tar.bz2 mitmproxy-0edc04814e3affa71025938ac354707b9b4c481c.zip |
small cleanups, working on tests
Diffstat (limited to 'netlib/websockets/implementations.py')
-rw-r--r-- | netlib/websockets/implementations.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/netlib/websockets/implementations.py b/netlib/websockets/implementations.py index 78ae5be6..ff42ff65 100644 --- a/netlib/websockets/implementations.py +++ b/netlib/websockets/implementations.py @@ -26,8 +26,8 @@ class WebSocketsEchoHandler(tcp.BaseHandler): self.on_message(decoded) def send_message(self, message): - frame = ws.WebSocketsFrame.default_frame_from_message(message, from_client = False) - self.wfile.write(frame.to_bytes()) + frame = ws.WebSocketsFrame.default(message, from_client = False) + self.wfile.write(frame.safe_to_bytes()) self.wfile.flush() def handshake(self): @@ -47,7 +47,7 @@ class WebSocketsClient(tcp.TCPClient): def __init__(self, address, source_address=None): super(WebSocketsClient, self).__init__(address, source_address) self.version = "13" - self.key = b64encode(os.urandom(16)).decode('utf-8') + self.key = ws.generate_client_nounce() self.resource = "/" def connect(self): @@ -76,6 +76,6 @@ class WebSocketsClient(tcp.TCPClient): self.close() def send_message(self, message): - frame = ws.WebSocketsFrame.default_frame_from_message(message, from_client = True) - self.wfile.write(frame.to_bytes()) + frame = ws.WebSocketsFrame.default(message, from_client = True) + self.wfile.write(frame.safe_to_bytes()) self.wfile.flush() |