aboutsummaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@corte.si>2018-05-05 10:05:43 +1200
committerGitHub <noreply@github.com>2018-05-05 10:05:43 +1200
commit9e283b27796ca29fd11d1862e025bae55ecfc56a (patch)
tree0609ccb8aee1cbe73266a69f131504a4b0cf9c6a /examples
parent165a4be7a963262e5a914a45dfb2a91b4c2ee5da (diff)
parentf5dc0aace180aea8ba5eadb84fd49c12e8d4af69 (diff)
downloadmitmproxy-9e283b27796ca29fd11d1862e025bae55ecfc56a.tar.gz
mitmproxy-9e283b27796ca29fd11d1862e025bae55ecfc56a.tar.bz2
mitmproxy-9e283b27796ca29fd11d1862e025bae55ecfc56a.zip
Merge pull request #3097 from cortesi/examp
Revamp dup_and_replay example
Diffstat (limited to 'examples')
-rw-r--r--examples/complex/dup_and_replay.py14
1 files changed, 10 insertions, 4 deletions
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])