MCPcopy Index your code
hub / github.com/mitmproxy/mitmproxy / modify

Function modify

examples/addons/http-stream-modify.py:14–21  ·  view source on GitHub ↗

This function will be called for each chunk of request/response body data that arrives at the proxy, and once at the end of the message with an empty bytes argument (b""). It may either return bytes or an iterable of bytes (which would result in multiple HTTP/2 data frames).

(data: bytes)

Source from the content-addressed store, hash-verified

12
13
14def modify(data: bytes) -> bytes | Iterable[bytes]:
15 """
16 This function will be called for each chunk of request/response body data that arrives at the proxy,
17 and once at the end of the message with an empty bytes argument (b"").
18
19 It may either return bytes or an iterable of bytes (which would result in multiple HTTP/2 data frames).
20 """
21 return data.replace(b"foo", b"bar")
22
23
24def responseheaders(flow):

Callers

nothing calls this directly

Calls 1

replaceMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…