mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-25 09:37:37 +00:00
22 lines
477 B
Python
22 lines
477 B
Python
"""Handle flows as command arguments."""
|
|
import typing
|
|
|
|
from mitmproxy import command
|
|
from mitmproxy import ctx
|
|
from mitmproxy import flow
|
|
from mitmproxy import http
|
|
|
|
|
|
class MyAddon:
|
|
@command.command("myaddon.addheader")
|
|
def addheader(self, flows: typing.Sequence[flow.Flow]) -> None:
|
|
for f in flows:
|
|
if isinstance(f, http.HTTPFlow):
|
|
f.request.headers["myheader"] = "value"
|
|
ctx.log.alert("done")
|
|
|
|
|
|
addons = [
|
|
MyAddon()
|
|
]
|