mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-23 00:01:36 +00:00
revert websocket changes from 73586b1b
The DEFAULT construct is very weird, but with None we apparently break pathod in some difficult-to-debug ways. Revisit once we do more here.
This commit is contained in:
parent
21579f0add
commit
9fbeac50ce
@ -14,6 +14,8 @@ from netlib import utils
|
||||
MAX_16_BIT_INT = (1 << 16)
|
||||
MAX_64_BIT_INT = (1 << 64)
|
||||
|
||||
DEFAULT=object()
|
||||
|
||||
OPCODE = utils.BiDi(
|
||||
CONTINUE=0x00,
|
||||
TEXT=0x01,
|
||||
@ -34,9 +36,9 @@ class FrameHeader(object):
|
||||
rsv1=False,
|
||||
rsv2=False,
|
||||
rsv3=False,
|
||||
masking_key=None,
|
||||
mask=None,
|
||||
length_code=None
|
||||
masking_key=DEFAULT,
|
||||
mask=DEFAULT,
|
||||
length_code=DEFAULT
|
||||
):
|
||||
if not 0 <= opcode < 2 ** 4:
|
||||
raise ValueError("opcode must be 0-16")
|
||||
@ -47,18 +49,18 @@ class FrameHeader(object):
|
||||
self.rsv2 = rsv2
|
||||
self.rsv3 = rsv3
|
||||
|
||||
if length_code is None:
|
||||
if length_code is DEFAULT:
|
||||
self.length_code = self._make_length_code(self.payload_length)
|
||||
else:
|
||||
self.length_code = length_code
|
||||
|
||||
if mask is None and masking_key is None:
|
||||
if mask is DEFAULT and masking_key is DEFAULT:
|
||||
self.mask = False
|
||||
self.masking_key = b""
|
||||
elif mask is None:
|
||||
elif mask is DEFAULT:
|
||||
self.mask = 1
|
||||
self.masking_key = masking_key
|
||||
elif masking_key is None:
|
||||
elif masking_key is DEFAULT:
|
||||
self.mask = mask
|
||||
self.masking_key = os.urandom(4)
|
||||
else:
|
||||
@ -166,7 +168,7 @@ class FrameHeader(object):
|
||||
if mask_bit == 1:
|
||||
masking_key = fp.safe_read(4)
|
||||
else:
|
||||
masking_key = False
|
||||
masking_key = None
|
||||
|
||||
return cls(
|
||||
fin=fin,
|
||||
@ -230,7 +232,7 @@ class Frame(object):
|
||||
masking_key = os.urandom(4)
|
||||
else:
|
||||
mask_bit = 0
|
||||
masking_key = False
|
||||
masking_key = None
|
||||
|
||||
return cls(
|
||||
message,
|
||||
@ -311,4 +313,4 @@ class Frame(object):
|
||||
def __eq__(self, other):
|
||||
if isinstance(other, Frame):
|
||||
return bytes(self) == bytes(other)
|
||||
return False
|
||||
return False
|
||||
|
Loading…
Reference in New Issue
Block a user