diff options
author | Thomas Kriechbaumer <thomas@kriechbaumer.name> | 2020-04-04 15:31:38 +0200 |
---|---|---|
committer | Thomas Kriechbaumer <thomas@kriechbaumer.name> | 2020-04-04 15:36:13 +0200 |
commit | 678be7a052007e26939b5f0cfa13200ab032cf86 (patch) | |
tree | 6c571ae26edff40621b85c1330d1f89d96094f10 /examples/simple | |
parent | 6acabbb4f5977427dd08adb0d32b06c0007315d2 (diff) | |
download | mitmproxy-678be7a052007e26939b5f0cfa13200ab032cf86.tar.gz mitmproxy-678be7a052007e26939b5f0cfa13200ab032cf86.tar.bz2 mitmproxy-678be7a052007e26939b5f0cfa13200ab032cf86.zip |
improve scripting docs
Diffstat (limited to 'examples/simple')
-rw-r--r-- | examples/simple/websocket_messages.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/examples/simple/websocket_messages.py b/examples/simple/websocket_messages.py index 719e7b10..071ea21f 100644 --- a/examples/simple/websocket_messages.py +++ b/examples/simple/websocket_messages.py @@ -6,8 +6,15 @@ def websocket_message(flow): # get the latest message message = flow.messages[-1] - # simply print the content of the message - ctx.log.info(message.content) + # was the message sent from the client or server? + if message.from_client: + ctx.log.info("Client sent a message: {}".format(message.content)) + else: + ctx.log.info("Server sent a message: {}".format(message.content)) # manipulate the message content message.content = re.sub(r'^Hello', 'HAPPY', message.content) + + if 'FOOBAR' in message.content: + # kill the message and not send it to the other endpoint + message.kill() |