@@ -47,6 +47,7 @@ class handshake_response(object):
|
|||||||
self.headers = headers
|
self.headers = headers
|
||||||
self.subprotocol = subprotocol
|
self.subprotocol = subprotocol
|
||||||
|
|
||||||
|
|
||||||
def handshake(sock, hostname, port, resource, **options):
|
def handshake(sock, hostname, port, resource, **options):
|
||||||
headers, key = _get_handshake_headers(resource, hostname, port, options)
|
headers, key = _get_handshake_headers(resource, hostname, port, options)
|
||||||
|
|
||||||
|
@@ -23,6 +23,12 @@ else:
|
|||||||
|
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
|
if six.PY3:
|
||||||
|
from base64 import decodebytes as base64decode
|
||||||
|
else:
|
||||||
|
from base64 import decodestring as base64decode
|
||||||
|
|
||||||
|
|
||||||
# websocket-client
|
# websocket-client
|
||||||
import websocket as ws
|
import websocket as ws
|
||||||
from websocket._handshake import _create_sec_websocket_key
|
from websocket._handshake import _create_sec_websocket_key
|
||||||
@@ -462,7 +468,7 @@ class WebSocketTest(unittest.TestCase):
|
|||||||
""" WebSocket key should be a UUID4.
|
""" WebSocket key should be a UUID4.
|
||||||
"""
|
"""
|
||||||
key = _create_sec_websocket_key()
|
key = _create_sec_websocket_key()
|
||||||
u = uuid.UUID(bytes=base64.b64decode(key))
|
u = uuid.UUID(bytes=base64decode(key.encode("utf-8")))
|
||||||
self.assertEqual(4, u.version)
|
self.assertEqual(4, u.version)
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user