Merge pull request #3097 from cortesi/examp

Revamp dup_and_replay example
This commit is contained in:
Aldo Cortesi 2018-05-05 10:05:43 +12:00 committed by GitHub
commit 9e283b2779
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 4 deletions

View File

@ -2,7 +2,13 @@ from mitmproxy import ctx
def request(flow): def request(flow):
f = flow.copy() # Avoid an infinite loop by not replaying already replayed requests
ctx.master.view.add(f) if flow.request.is_replay:
f.request.path = "/changed" return
ctx.master.replay_request(f, block=True) 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])

View File

@ -293,6 +293,7 @@ class View(collections.Sequence):
self._refilter() self._refilter()
self.sig_store_refresh.send(self) self.sig_store_refresh.send(self)
@command.command("view.marked.toggle")
def add(self, flows: typing.Sequence[mitmproxy.flow.Flow]) -> None: def add(self, flows: typing.Sequence[mitmproxy.flow.Flow]) -> None:
""" """
Adds a flow to the state. If the flow already exists, it is Adds a flow to the state. If the flow already exists, it is