MCPcopy Create free account
hub / github.com/mitmproxy/mitmproxy / inject_websocket

Method inject_websocket

mitmproxy/addons/proxyserver.py:336–350  ·  view source on GitHub ↗
(
        self, flow: Flow, to_client: bool, message: bytes, is_text: bool = True
    )

Source from the content-addressed store, hash-verified

334
335 @command.command("inject.websocket")
336 def inject_websocket(
337 self, flow: Flow, to_client: bool, message: bytes, is_text: bool = True
338 ):
339 if not isinstance(flow, http.HTTPFlow) or not flow.websocket:
340 logger.warning("Cannot inject WebSocket messages into non-WebSocket flows.")
341 return
342
343 msg = websocket.WebSocketMessage(
344 Opcode.TEXT if is_text else Opcode.BINARY, not to_client, message
345 )
346 event = WebSocketMessageInjected(flow, msg)
347 try:
348 self.inject_event(event)
349 except ValueError as e:
350 logger.warning(str(e))
351
352 @command.command("inject.tcp")
353 def inject_tcp(self, flow: Flow, to_client: bool, message: bytes):

Callers 1

test_inject_failFunction · 0.95

Calls 2

inject_eventMethod · 0.95

Tested by 1

test_inject_failFunction · 0.76