diff options
Diffstat (limited to 'examples')
-rw-r--r-- | examples/addons/events.py | 5 | ||||
-rw-r--r-- | examples/complex/dup_and_replay.py | 14 |
2 files changed, 10 insertions, 9 deletions
diff --git a/examples/addons/events.py b/examples/addons/events.py index 674ab4c8..cd714ba0 100644 --- a/examples/addons/events.py +++ b/examples/addons/events.py @@ -167,11 +167,6 @@ class Events: loaded. """ - def tick(self): - """ - A regular ticker - called approximately once every 100ms. - """ - def update(self, flows: typing.Sequence[mitmproxy.flow.Flow]): """ Update is called when one or more flow objects have been modified, diff --git a/examples/complex/dup_and_replay.py b/examples/complex/dup_and_replay.py index 2baa1ea6..adcebff3 100644 --- a/examples/complex/dup_and_replay.py +++ b/examples/complex/dup_and_replay.py @@ -2,7 +2,13 @@ from mitmproxy import ctx def request(flow): - f = flow.copy() - ctx.master.view.add(f) - f.request.path = "/changed" - ctx.master.replay_request(f, block=True) + # Avoid an infinite loop by not replaying already replayed requests + if flow.request.is_replay: + return + flow = flow.copy() + # Only interactive tools have a view. If we have one, add a duplicate entry + # for our flow. + if "view" in ctx.master.addons: + ctx.master.commands.call("view.add", [flow]) + flow.request.path = "/changed" + ctx.master.commands.call("replay.client", [flow]) |