aboutsummaryrefslogtreecommitdiffstats
path: root/examples/simple/websocket_messages.py
blob: 719e7b108fc0d3df000ddd596dc9238ee92cd484 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
import re
from mitmproxy import ctx


def websocket_message(flow):
    # get the latest message
    message = flow.messages[-1]

    # simply print the content of the message
    ctx.log.info(message.content)

    # manipulate the message content
    message.content = re.sub(r'^Hello', 'HAPPY', message.content)