aboutsummaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@corte.si>2017-04-26 11:01:27 +1200
committerAldo Cortesi <aldo@corte.si>2017-04-26 11:01:27 +1200
commitb72f1390937e9799f588fd9a1564056131fb1aa7 (patch)
tree2396e9f5c272e671e45e8e4c4abee30ad34b3448 /examples
parentf90b4c2ff0f3fd71350900c10dea2a67846e1bdb (diff)
downloadmitmproxy-b72f1390937e9799f588fd9a1564056131fb1aa7.tar.gz
mitmproxy-b72f1390937e9799f588fd9a1564056131fb1aa7.tar.bz2
mitmproxy-b72f1390937e9799f588fd9a1564056131fb1aa7.zip
configure(options, updated) -> configure(updated)
Options are now available globally on ctx, so the first argument of configure is redundant.
Diffstat (limited to 'examples')
-rw-r--r--examples/simple/custom_option.py4
-rw-r--r--examples/simple/modify_body_inject_iframe.py11
2 files changed, 5 insertions, 10 deletions
diff --git a/examples/simple/custom_option.py b/examples/simple/custom_option.py
index c8bc98d4..5b6070dd 100644
--- a/examples/simple/custom_option.py
+++ b/examples/simple/custom_option.py
@@ -6,6 +6,6 @@ def load(l):
l.add_option("custom", bool, False, "A custom option")
-def configure(options, updated):
+def configure(updated):
if "custom" in updated:
- ctx.log.info("custom option value: %s" % options.custom)
+ ctx.log.info("custom option value: %s" % ctx.options.custom)
diff --git a/examples/simple/modify_body_inject_iframe.py b/examples/simple/modify_body_inject_iframe.py
index d54468d2..dff72afa 100644
--- a/examples/simple/modify_body_inject_iframe.py
+++ b/examples/simple/modify_body_inject_iframe.py
@@ -1,26 +1,21 @@
# (this script works best with --anticache)
from bs4 import BeautifulSoup
+from mitmproxy import ctx
class Injector:
- def __init__(self):
- self.iframe_url = None
-
def load(self, loader):
loader.add_option(
"iframe", str, "", "IFrame to inject"
)
- def configure(self, options, updated):
- self.iframe_url = options.iframe
-
def response(self, flow):
- if self.iframe_url:
+ if ctx.options.iframe:
html = BeautifulSoup(flow.response.content, "html.parser")
if html.body:
iframe = html.new_tag(
"iframe",
- src=self.iframe_url,
+ src=ctx.options.iframe,
frameborder=0,
height=0,
width=0)