diff --git a/mitmproxy/console/common.py b/mitmproxy/console/common.py index 1c71117a7..c143f0c99 100644 --- a/mitmproxy/console/common.py +++ b/mitmproxy/console/common.py @@ -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) diff --git a/mitmproxy/console/flowlist.py b/mitmproxy/console/flowlist.py index e8bbe24df..5b1701d80 100644 --- a/mitmproxy/console/flowlist.py +++ b/mitmproxy/console/flowlist.py @@ -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": diff --git a/mitmproxy/console/flowview.py b/mitmproxy/console/flowview.py index c85a9f739..9b89be98e 100644 --- a/mitmproxy/console/flowview.py +++ b/mitmproxy/console/flowview.py @@ -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"),