Merge pull request #1551 from cortesi/sreplay

console: fix/improve server replay
This commit is contained in:
Aldo Cortesi 2016-09-11 17:48:30 +12:00 committed by GitHub
commit c3f07f354f
3 changed files with 26 additions and 44 deletions

View File

@ -18,14 +18,15 @@ def _mkhelp():
("d", "delete flow"),
("D", "duplicate flow"),
("e", "toggle eventlog"),
("E", "export flow to file"),
("f", "filter view"),
("F", "toggle follow flow list"),
("L", "load saved flows"),
("m", "toggle flow mark"),
("M", "toggle marked flow view"),
("n", "create a new request"),
("E", "export flow to file"),
("r", "replay request"),
("S", "server replay request/s"),
("U", "unmark all marked flows"),
("V", "revert changes to request"),
("w", "save flows "),
@ -140,36 +141,13 @@ class ConnectionItem(urwid.WidgetWrap):
args = (self.flow,)
)
def stop_server_playback_prompt(self, a):
if a != "n":
self.master.stop_server_playback()
def server_replay_prompt(self, k):
a = self.master.addons.get("serverplayback")
if k == "a":
self.master.start_server_playback(
[i.copy() for i in self.master.state.view],
self.master.options.replay_kill_extra, self.master.options.server_replay_use_headers,
False, self.master.options.server_replay_nopop,
self.master.options.server_replay_ignore_params,
self.master.options.server_replay_ignore_content,
self.master.options.server_replay_ignore_payload_params,
self.master.options.server_replay_ignore_host
)
a.load([i.copy() for i in self.master.state.view])
elif k == "t":
self.master.start_server_playback(
[self.flow.copy()],
self.master.options.replay_kill_extra, self.master.options.server_replay_use_headers,
False, self.master.options.server_replay_nopop,
self.master.options.server_replay_ignore_params,
self.master.options.server_replay_ignore_content,
self.master.options.server_replay_ignore_payload_params,
self.master.options.server_replay_ignore_host
)
else:
signals.status_prompt_path.send(
prompt = "Server replay path",
callback = self.master.server_playback_path
)
a.load([self.flow.copy()])
signals.update_settings.send(self)
def mouse_event(self, size, event, button, col, row, focus):
if event == "mouse press" and button == 1:
@ -207,24 +185,27 @@ class ConnectionItem(urwid.WidgetWrap):
signals.status_message.send(message=r)
signals.flowlist_change.send(self)
elif key == "S":
if not self.master.server_playback:
signals.status_prompt_onekey.send(
prompt = "Server Replay",
keys = (
("all flows", "a"),
("this flow", "t"),
("file", "f"),
),
callback = self.server_replay_prompt,
)
else:
def stop_server_playback(response):
if response == "y":
self.master.options.server_replay = []
a = self.master.addons.get("serverplayback")
if a.count():
signals.status_prompt_onekey.send(
prompt = "Stop current server replay?",
keys = (
("yes", "y"),
("no", "n"),
),
callback = self.stop_server_playback_prompt,
callback = stop_server_playback,
)
else:
signals.status_prompt_onekey.send(
prompt = "Server Replay",
keys = (
("all flows", "a"),
("this flow", "t"),
),
callback = self.server_replay_prompt,
)
elif key == "U":
for f in self.state.flows:

View File

@ -53,7 +53,7 @@ class HelpView(urwid.ListBox):
("o", "options"),
("q", "quit / return to previous page"),
("Q", "quit without confirm prompt"),
("R", "replay of HTTP requests/responses"),
("R", "replay of requests/responses from file"),
]
text.extend(
common.format_keyvals(keys, key="key", val="text", indent=4)

View File

@ -136,6 +136,8 @@ class StatusBar(urwid.WidgetWrap):
def get_status(self):
r = []
sreplay = self.master.addons.get("serverplayback")
if len(self.master.options.setheaders):
r.append("[")
r.append(("heading_key", "H"))
@ -148,11 +150,10 @@ class StatusBar(urwid.WidgetWrap):
r.append("[")
r.append(("heading_key", "cplayback"))
r.append(":%s]" % self.master.client_playback.count())
if self.master.options.server_replay:
if sreplay.count():
r.append("[")
r.append(("heading_key", "splayback"))
a = self.master.addons.get("serverplayback")
r.append(":%s]" % a.count())
r.append(":%s]" % sreplay.count())
if self.master.options.ignore_hosts:
r.append("[")
r.append(("heading_key", "I"))