mitmproxy/examples/addons/commands-flows.py

22 lines
493 B
Python
Raw Normal View History

"""Handle flows as command arguments."""
2022-04-26 11:53:23 +00:00
from collections.abc import Sequence
from mitmproxy import command
from mitmproxy import ctx
from mitmproxy import flow
2021-02-03 22:00:41 +00:00
from mitmproxy import http
class MyAddon:
@command.command("myaddon.addheader")
2022-04-26 11:53:23 +00:00
def addheader(self, flows: Sequence[flow.Flow]) -> None:
for f in flows:
2021-02-03 22:00:41 +00:00
if isinstance(f, http.HTTPFlow):
f.request.headers["myheader"] = "value"
ctx.log.alert("done")
addons = [
MyAddon()
]