Skip to content

Commit

Permalink
fix websocket regression introduced in 7.0.1 (#4733)
Browse files Browse the repository at this point in the history
  • Loading branch information
mhils committed Aug 4, 2021
1 parent 88374e9 commit 53a916e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion mitmproxy/proxy/layers/websocket.py
Expand Up @@ -164,7 +164,7 @@ def relay_messages(self, event: events.Event) -> layer.CommandGenerator[None]:
content = b"".join(src_ws.frame_buf)

fragmentizer = Fragmentizer(src_ws.frame_buf, is_text)
src_ws.frame_buf.clear()
src_ws.frame_buf = [b""]

message = websocket.WebSocketMessage(typ, from_client, content)
self.flow.websocket.messages.append(message)
Expand Down
6 changes: 5 additions & 1 deletion test/mitmproxy/proxy/layers/test_websocket.py
Expand Up @@ -95,8 +95,12 @@ def test_upgrade(tctx):
<< websocket.WebsocketMessageHook(flow)
>> reply()
<< SendData(tctx.client, b"\x82\nhello back")
>> DataReceived(tctx.client, masked_bytes(b"\x81\x0bhello again"))
<< websocket.WebsocketMessageHook(flow)
>> reply()
<< SendData(tctx.server, masked(b"\x81\x0bhello again"))
)
assert len(flow().websocket.messages) == 2
assert len(flow().websocket.messages) == 3
assert flow().websocket.messages[0].content == b"hello world"
assert flow().websocket.messages[0].from_client
assert flow().websocket.messages[0].type == Opcode.TEXT
Expand Down

0 comments on commit 53a916e

Please sign in to comment.