Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix websocket regression introduced in 7.0.1 #4733

Merged
merged 1 commit into from Aug 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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