mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-23 00:01:36 +00:00
Export to file (p) or clipboard (P)
This commit is contained in:
parent
6119f0f16a
commit
5cf2228250
@ -284,12 +284,6 @@ def copy_flow_format_data(part, scope, flow):
|
||||
return data, False
|
||||
|
||||
|
||||
def export_prompt(k, f):
|
||||
for exporter in flow.export.EXPORTERS:
|
||||
if k == exporter[1]:
|
||||
copy_to_clipboard_or_prompt(exporter[2](f))
|
||||
|
||||
|
||||
def copy_to_clipboard_or_prompt(data):
|
||||
# pyperclip calls encode('utf-8') on data to be copied without checking.
|
||||
# if data are already encoded that way UnicodeDecodeError is thrown.
|
||||
@ -395,6 +389,18 @@ def ask_save_body(part, master, state, flow):
|
||||
signals.status_message.send(message="No content to save.")
|
||||
|
||||
|
||||
def export_to_clipboard(k, f):
|
||||
for exporter in flow.export.EXPORTERS:
|
||||
if k == exporter[1]:
|
||||
copy_to_clipboard_or_prompt(exporter[2](f))
|
||||
|
||||
|
||||
def export_to_file(k, f):
|
||||
for exporter in flow.export.EXPORTERS:
|
||||
if k == exporter[1]:
|
||||
ask_save_path("File path", exporter[2](f))
|
||||
|
||||
|
||||
flowcache = utils.LRUCache(800)
|
||||
|
||||
|
||||
|
@ -17,7 +17,6 @@ def _mkhelp():
|
||||
("C", "clear flow list or eventlog"),
|
||||
("d", "delete flow"),
|
||||
("D", "duplicate flow"),
|
||||
("E", "export"),
|
||||
("e", "toggle eventlog"),
|
||||
("F", "toggle follow flow list"),
|
||||
("l", "set limit filter pattern"),
|
||||
@ -25,7 +24,8 @@ def _mkhelp():
|
||||
("m", "toggle flow mark"),
|
||||
("M", "toggle marked flow view"),
|
||||
("n", "create a new request"),
|
||||
("P", "copy flow to clipboard"),
|
||||
("p", "export flow to file"),
|
||||
("P", "export flow to clipboard"),
|
||||
("r", "replay request"),
|
||||
("U", "unmark all marked flows"),
|
||||
("V", "revert changes to request"),
|
||||
@ -264,14 +264,20 @@ class ConnectionItem(urwid.WidgetWrap):
|
||||
callback = self.master.run_script_once,
|
||||
args = (self.flow,)
|
||||
)
|
||||
elif key == "P":
|
||||
common.ask_copy_part("a", self.flow, self.master, self.state)
|
||||
elif key == "E":
|
||||
elif key == "p":
|
||||
signals.status_prompt_onekey.send(
|
||||
self,
|
||||
prompt = "Export",
|
||||
prompt = "Export to file",
|
||||
keys = [(e[0], e[1]) for e in export.EXPORTERS],
|
||||
callback = common.export_prompt,
|
||||
callback = common.export_to_file,
|
||||
args = (self.flow,)
|
||||
)
|
||||
elif key == "P":
|
||||
signals.status_prompt_onekey.send(
|
||||
self,
|
||||
prompt = "Export to clipboard",
|
||||
keys = [(e[0], e[1]) for e in export.EXPORTERS],
|
||||
callback = common.export_to_clipboard,
|
||||
args = (self.flow,)
|
||||
)
|
||||
elif key == "b":
|
||||
|
@ -34,7 +34,6 @@ def _mkhelp():
|
||||
("b", "save request/response body"),
|
||||
("D", "duplicate flow"),
|
||||
("d", "delete flow"),
|
||||
("E", "export"),
|
||||
("e", "edit request/response"),
|
||||
("f", "load full body data"),
|
||||
("m", "change body display mode for this entity"),
|
||||
|
Loading…
Reference in New Issue
Block a user