diff --git a/libmproxy/console/__init__.py b/libmproxy/console/__init__.py index 1e5524d8d..6940b4826 100644 --- a/libmproxy/console/__init__.py +++ b/libmproxy/console/__init__.py @@ -154,6 +154,10 @@ class StatusBar(common.WWrap): r.append("[") r.append(("heading_key", "P")) r.append(":%s]"%utils.unparse_url(*self.master.server.config.reverse_proxy)) + if self.master.state.default_body_view != contentview.VIEW_AUTO: + r.append("[") + r.append(("heading_key", "M")) + r.append(":%s]"%contentview.VIEW_NAMES[self.master.state.default_body_view]) opts = [] if self.master.anticache: @@ -677,6 +681,12 @@ class ConsoleMaster(flow.FlowMaster): def set_intercept(self, txt): return self.state.set_intercept(txt) + def change_default_display_mode(self, t): + v = contentview.VIEW_SHORTCUTS.get(t) + self.state.default_body_view = v + if self.currentflow: + self.refresh_flow(self.currentflow) + def set_reverse_proxy(self, txt): if not txt: self.server.config.reverse_proxy = None @@ -769,6 +779,12 @@ class ConsoleMaster(flow.FlowMaster): ), self.quit, ) + elif k == "M": + self.prompt_onekey( + "Global default display mode", + contentview.VIEW_PROMPT, + self.change_default_display_mode + ) elif k == "P": if self.server.config.reverse_proxy: p = utils.unparse_url(*self.server.config.reverse_proxy) diff --git a/libmproxy/console/contentview.py b/libmproxy/console/contentview.py index 1d621ae25..ab08602f0 100644 --- a/libmproxy/console/contentview.py +++ b/libmproxy/console/contentview.py @@ -30,12 +30,26 @@ VIEW_NAMES = { VIEW_HEX: "Hex", } + +VIEW_PROMPT = ( + ("auto detect", "a"), + ("hex", "h"), + ("image", "i"), + ("javascript", "j"), + ("json", "s"), + ("raw", "r"), + ("multipart", "m"), + ("urlencoded", "u"), + ("xmlish", "x"), +) + VIEW_SHORTCUTS = { "a": VIEW_AUTO, "i": VIEW_IMAGE, "j": VIEW_JAVASCRIPT, "s": VIEW_JSON, "u": VIEW_URLENCODED, + "m": VIEW_MULTIPART, "x": VIEW_XML, "r": VIEW_RAW, "h": VIEW_HEX, diff --git a/libmproxy/console/flowview.py b/libmproxy/console/flowview.py index 9dbbcf50d..30697c9c7 100644 --- a/libmproxy/console/flowview.py +++ b/libmproxy/console/flowview.py @@ -378,11 +378,6 @@ class FlowView(common.WWrap): ) self.master.refresh_flow(self.flow) - def change_default_display_mode(self, t): - v = contentview.VIEW_SHORTCUTS.get(t) - self.state.default_body_view = v - self.master.refresh_flow(self.flow) - def keypress(self, size, key): if key == " ": self.view_next_flow(self.flow) @@ -455,35 +450,10 @@ class FlowView(common.WWrap): elif key == "m": self.master.prompt_onekey( "Display mode", - ( - ("auto detect", "a"), - ("hex", "h"), - ("image", "i"), - ("javascript", "j"), - ("json", "s"), - ("raw", "r"), - ("urlencoded", "u"), - ("xmlish", "x"), - ), + contentview.VIEW_PROMPT, self.change_this_display_mode ) key = None - elif key == "M": - self.master.prompt_onekey( - "Global default display mode", - ( - ("auto detect", "a"), - ("hex", "h"), - ("image", "i"), - ("javascript", "j"), - ("json", "s"), - ("raw", "r"), - ("urlencoded", "u"), - ("xmlish", "x"), - ), - self.change_default_display_mode - ) - key = None elif key == "p": self.view_prev_flow(self.flow) elif key == "r": diff --git a/libmproxy/console/help.py b/libmproxy/console/help.py index 97118aee1..9abdcd12d 100644 --- a/libmproxy/console/help.py +++ b/libmproxy/console/help.py @@ -62,6 +62,39 @@ class HelpView(urwid.ListBox): keys = [ ("c", "client replay"), ("i", "set interception pattern"), + ("M", "change global default display mode"), + (None, + common.highlight_key("automatic", "a") + + [("text", ": automatic detection")] + ), + (None, + common.highlight_key("hex", "h") + + [("text", ": Hex")] + ), + (None, + common.highlight_key("image", "i") + + [("text", ": Image")] + ), + (None, + common.highlight_key("javascript", "j") + + [("text", ": JavaScript")] + ), + (None, + common.highlight_key("json", "s") + + [("text", ": JSON")] + ), + (None, + common.highlight_key("urlencoded", "u") + + [("text", ": URL-encoded data")] + ), + (None, + common.highlight_key("raw", "r") + + [("text", ": raw data")] + ), + (None, + common.highlight_key("xml", "x") + + [("text", ": XML")] + ), ("o", "toggle options:"), (None,