diff --git a/mitmproxy/net/websockets/frame.py b/mitmproxy/net/websockets/frame.py index ac6a08128..7b93bc245 100644 --- a/mitmproxy/net/websockets/frame.py +++ b/mitmproxy/net/websockets/frame.py @@ -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: diff --git a/test/mitmproxy/net/websockets/test_frame.py b/test/mitmproxy/net/websockets/test_frame.py index 2a5bd5561..f5c29c21b 100644 --- a/test/mitmproxy/net/websockets/test_frame.py +++ b/test/mitmproxy/net/websockets/test_frame.py @@ -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: diff --git a/test/pathod/language/test_websockets.py b/test/pathod/language/test_websockets.py index ed766bca6..64ff024c9 100644 --- a/test/pathod/language/test_websockets.py +++ b/test/pathod/language/test_websockets.py @@ -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")