aboutsummaryrefslogtreecommitdiffstats
path: root/examples/addons/commands-flows.py
diff options
context:
space:
mode:
authorkira0204 <rshtmudgal@gmail.com>2018-02-24 12:42:21 +0530
committerkira0204 <rshtmudgal@gmail.com>2018-02-24 12:42:21 +0530
commit8209b89d41bdfc3b6a9a3dd5d9054b02722e0d4f (patch)
tree5691f1dd11ac1b2a98e57ed06252ff7dc40cd555 /examples/addons/commands-flows.py
parent69dbd1da61e6e452da63c63fba1d810b269f459d (diff)
parenteee109117f956600261bc938be52040d1474a97f (diff)
downloadmitmproxy-8209b89d41bdfc3b6a9a3dd5d9054b02722e0d4f.tar.gz
mitmproxy-8209b89d41bdfc3b6a9a3dd5d9054b02722e0d4f.tar.bz2
mitmproxy-8209b89d41bdfc3b6a9a3dd5d9054b02722e0d4f.zip
Merge branch 'master' of https://github.com/kira0204/mitmproxy into update-readme
Diffstat (limited to 'examples/addons/commands-flows.py')
-rw-r--r--examples/addons/commands-flows.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/examples/addons/commands-flows.py b/examples/addons/commands-flows.py
new file mode 100644
index 00000000..cebc8f9d
--- /dev/null
+++ b/examples/addons/commands-flows.py
@@ -0,0 +1,21 @@
+import typing
+
+from mitmproxy import command
+from mitmproxy import ctx
+from mitmproxy import flow
+
+
+class MyAddon:
+ def __init__(self):
+ self.num = 0
+
+ @command.command("myaddon.addheader")
+ def addheader(self, flows: typing.Sequence[flow.Flow]) -> None:
+ for f in flows:
+ f.request.headers["myheader"] = "value"
+ ctx.log.alert("done")
+
+
+addons = [
+ MyAddon()
+]