mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-23 00:01:36 +00:00
improve websocket frame masking api
This commit is contained in:
parent
9047c4f2a5
commit
be26958ea8
@ -71,7 +71,7 @@ class FrameHeader:
|
||||
else:
|
||||
self.length_code = length_code
|
||||
|
||||
if mask is DEFAULT and masking_key is DEFAULT:
|
||||
if (mask is DEFAULT and masking_key is DEFAULT) or mask == 0 or mask is False:
|
||||
self.mask = False
|
||||
self.masking_key = b""
|
||||
elif mask is DEFAULT:
|
||||
|
@ -122,7 +122,7 @@ class TestFrameHeader:
|
||||
|
||||
f = websockets.FrameHeader(masking_key=b"foob", mask=0)
|
||||
assert not f.mask
|
||||
assert f.masking_key
|
||||
assert not f.masking_key
|
||||
|
||||
|
||||
class TestFrame:
|
||||
|
@ -123,12 +123,6 @@ class TestWebsocketFrame:
|
||||
assert not frm.header.mask
|
||||
assert not frm.header.masking_key
|
||||
|
||||
frm = self.fr("wf:b'foo':-mask:k'abcd'", is_client=True)
|
||||
assert not frm.header.mask
|
||||
# We're reading back a corrupted frame - the first 3 characters of the
|
||||
# mask is mis-interpreted as the payload
|
||||
assert frm.payload == b"abc"
|
||||
|
||||
def test_knone(self):
|
||||
with pytest.raises(Exception, match="Expected 4 bytes"):
|
||||
self.fr("wf:b'foo':mask:knone")
|
||||
|
Loading…
Reference in New Issue
Block a user