aboutsummaryrefslogtreecommitdiffstats
path: root/netlib/websockets.py
diff options
context:
space:
mode:
Diffstat (limited to 'netlib/websockets.py')
-rw-r--r--netlib/websockets.py17
1 files changed, 2 insertions, 15 deletions
diff --git a/netlib/websockets.py b/netlib/websockets.py
index a03185fa..0cd4dba1 100644
--- a/netlib/websockets.py
+++ b/netlib/websockets.py
@@ -29,10 +29,6 @@ class CONST(object):
MAX_64_BIT_INT = (1 << 64)
-class WebSocketFrameValidationException(Exception):
- pass
-
-
class Frame(object):
"""
Represents one websockets frame.
@@ -95,7 +91,8 @@ class Frame(object):
if from_client:
mask_bit = 1
- masking_key = random_masking_key()
+ # Random masking key
+ masking_key = os.urandom(4)
payload = apply_mask(message, masking_key)
else:
mask_bit = 0
@@ -164,12 +161,6 @@ class Frame(object):
"""
return cls.from_file(io.BytesIO(bytestring))
- def safe_to_bytes(self):
- if self.is_valid():
- return self.to_bytes()
- else:
- raise WebSocketFrameValidationException()
-
def to_bytes(self):
"""
Serialize the frame back into the wire format, returns a bytestring
@@ -308,10 +299,6 @@ def apply_mask(message, masking_key):
return result
-def random_masking_key():
- return os.urandom(4)
-
-
def client_handshake_headers(key=None, version=VERSION):
"""
Create the headers for a valid HTTP upgrade request. If Key is not