From 6cb40d03f4d9f735f383effa4209b4764bb13955 Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Sun, 13 Mar 2011 21:16:42 +1300 Subject: [PATCH] Fix a number of small UI infelicities. - Make request/response view switching behave sensibly - Avoid having an empty string appear in connection view text. This makes urwid misbehave. - Make it clear that intercept and cookies specifications are filters. --- libmproxy/console.py | 30 ++++++++++++++---------------- mitmproxy | 2 ++ 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/libmproxy/console.py b/libmproxy/console.py index 996b845cd..c327692f1 100644 --- a/libmproxy/console.py +++ b/libmproxy/console.py @@ -53,13 +53,11 @@ def format_keyvals(lst, key="key", val="text", space=5, indent=0): def format_flow(f, focus, extended=False, padding=2): + txt = [] if extended: - ts = ("highlight", utils.format_timestamp(f.request.timestamp)) - else: - ts = "" - - txt = [ - ts, + txt.append(("highlight", utils.format_timestamp(f.request.timestamp))) + txt.append(" ") + txt.extend([ ("ack", "!") if f.intercepting and not f.request.acked else " ", ("method", f.request.method), " ", @@ -67,7 +65,7 @@ def format_flow(f, focus, extended=False, padding=2): "text" if (f.response or f.error) else "title", f.request.url(), ), - ] + ]) if f.response or f.error or f.request.is_replay(): tsr = f.response or f.error if extended and tsr: @@ -247,10 +245,10 @@ class ConnectionView(WWrap): ] def __init__(self, master, state, flow): self.master, self.state, self.flow = master, state, flow - if self.state.view_flow_mode == VIEW_FLOW_REQUEST: - self.view_request() - else: + if self.state.view_flow_mode == VIEW_FLOW_RESPONSE and flow.response: self.view_response() + else: + self.view_request() def _tab(self, content, active): if active: @@ -359,10 +357,10 @@ class ConnectionView(WWrap): def refresh_connection(self, c=None): if c == self.flow: - if self.state.view_flow_mode == VIEW_FLOW_REQUEST: - self.view_request() - else: + if self.state.view_flow_mode == VIEW_FLOW_RESPONSE and flow.response: self.view_response() + else: + self.view_request() def _spawn_editor(self, data): fd, name = tempfile.mkstemp('', "mproxy") @@ -471,7 +469,7 @@ class ConnectionView(WWrap): def keypress(self, size, key): if key == "tab": - if self.state.view_flow_mode == VIEW_FLOW_REQUEST: + if self.state.view_flow_mode == VIEW_FLOW_REQUEST and self.flow.response: self.view_response() else: self.view_request() @@ -1315,7 +1313,7 @@ class ConsoleMaster(flow.FlowMaster): k = None elif k == "i": self.prompt( - "Intercept: ", + "Intercept filter: ", self.state.intercept_txt, self.set_intercept ) @@ -1379,7 +1377,7 @@ class ConsoleMaster(flow.FlowMaster): k = None elif k == "t": self.prompt( - "Sticky cookie: ", + "Sticky cookie filter: ", self.stickycookie_txt, self.set_stickycookie ) diff --git a/mitmproxy b/mitmproxy index f6c4653c7..76011f95f 100755 --- a/mitmproxy +++ b/mitmproxy @@ -55,6 +55,8 @@ if __name__ == '__main__': sys.exit(1) opts = console.Options(**cmdline.get_common_options(options)) + opts.intercept = options.intercept + opts.limit = options.limit m = console.ConsoleMaster(server, opts) for i in args: