mirror of
https://github.com/vee1e/mitmproxy.git
synced 2026-09-01 18:27:18 +00:00
* update ws injection example, fixes #4751 * Update websocket-inject-message.py * Revert "Update websocket-inject-message.py" This reverts commit 86b4cda2f4d6d694db7d0d8b30ec04c3ef123181. Co-authored-by: Maximilian Hils <github@maximilianhils.com> Co-authored-by: Maximilian Hils <git@maximilianhils.com>
This commit is contained in:
parent
b36ce70ead
commit
edbb3d6791
1 changed files with 3 additions and 3 deletions
|
|
@ -13,9 +13,9 @@ from mitmproxy import ctx, http
|
|||
def websocket_message(flow: http.HTTPFlow):
|
||||
assert flow.websocket is not None # make type checker happy
|
||||
last_message = flow.websocket.messages[-1]
|
||||
if b"secret" in last_message.content:
|
||||
if last_message.is_text and "secret" in last_message.text:
|
||||
last_message.drop()
|
||||
ctx.master.commands.call("inject.websocket", flow, last_message.from_client, "ssssssh")
|
||||
ctx.master.commands.call("inject.websocket", flow, last_message.from_client, "ssssssh".encode())
|
||||
|
||||
|
||||
# Complex example: Schedule a periodic timer
|
||||
|
|
@ -24,7 +24,7 @@ async def inject_async(flow: http.HTTPFlow):
|
|||
msg = "hello from mitmproxy! "
|
||||
assert flow.websocket is not None # make type checker happy
|
||||
while flow.websocket.timestamp_end is None:
|
||||
ctx.master.commands.call("inject.websocket", flow, True, msg)
|
||||
ctx.master.commands.call("inject.websocket", flow, True, msg.encode())
|
||||
await asyncio.sleep(1)
|
||||
msg = msg[1:] + msg[:1]
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue