From b3901a76527d9ce0f0429810147e5035f871e36a Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Wed, 16 May 2012 18:16:44 +1200 Subject: [PATCH] Add interface to mark content missing, and extend UI to indicate when content is missing. --- libmproxy/console/common.py | 10 ++++++++-- libmproxy/console/flowview.py | 31 +++++++++++++++++++++++++++++-- 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/libmproxy/console/common.py b/libmproxy/console/common.py index 2d4c98eaf..8fc592c4c 100644 --- a/libmproxy/console/common.py +++ b/libmproxy/console/common.py @@ -15,7 +15,7 @@ import urwid import urwid.util -from .. import utils +from .. import utils, flow @@ -191,11 +191,17 @@ def format_flow(f, focus, extended=False, padding=2): resp_code = f.response.code if f.response else None, ) if f.response: + if f.response.content: + contentdesc = utils.pretty_size(len(f.response.content)) + elif f.response.content == flow.CONTENT_MISSING: + contentdesc = "[content missing]" + else: + contentdesc = "[no content]" d.update(dict( resp_code = f.response.code, resp_is_replay = f.response.is_replay(), resp_acked = f.response.acked, - resp_clen = utils.pretty_size(len(f.response.content)) if f.response.content else "[empty content]" + resp_clen = contentdesc )) t = f.response.headers["content-type"] if t: diff --git a/libmproxy/console/flowview.py b/libmproxy/console/flowview.py index bc8450b9b..ee85884e3 100644 --- a/libmproxy/console/flowview.py +++ b/libmproxy/console/flowview.py @@ -68,6 +68,7 @@ def _mkhelp(): ("v", "view body in external viewer"), ("w", "save all flows matching current limit"), ("W", "save this flow"), + ("x", "delete body"), ("X", "view flow details"), ("z", "encode/decode a request/response"), ("tab", "toggle request/response view"), @@ -153,14 +154,17 @@ class FlowView(common.WWrap): key = "header", val = "text" ) - if conn.content: + if conn.content is not None: override = self.state.get_flow_setting( self.flow, (self.state.view_flow_mode, "prettyview"), ) viewmode = self.state.default_body_view if override is None else override - msg, body = self.content_view(viewmode, conn) + if conn.content == flow.CONTENT_MISSING: + msg, body = "", [urwid.Text([("error", "[content missing]")])] + else: + msg, body = self.content_view(viewmode, conn) cols = [ urwid.Text( @@ -184,6 +188,8 @@ class FlowView(common.WWrap): title = urwid.AttrWrap(urwid.Columns(cols), "heading") txt.append(title) txt.extend(body) + elif conn.content == flow.CONTENT_MISSING: + pass return urwid.ListBox(txt) def _tab(self, content, attr): @@ -390,6 +396,17 @@ class FlowView(common.WWrap): ) self.master.refresh_flow(self.flow) + def delete_body(self, t): + if t == "m": + val = flow.CONTENT_MISSING + else: + val = None + if self.state.view_flow_mode == common.VIEW_FLOW_REQUEST: + self.flow.request.content = val + else: + self.flow.response.content = val + self.master.refresh_flow(self.flow) + def keypress(self, size, key): if key == " ": self.view_next_flow(self.flow) @@ -523,6 +540,16 @@ class FlowView(common.WWrap): "Send flow to script: ", self.state.last_script, self.master.run_script_once, self.flow ) + elif key == "x": + self.master.prompt_onekey( + "Delete body", + ( + ("completely", "c"), + ("mark as missing", "m"), + ), + self.delete_body + ) + key = None elif key == "X": self.master.view_flowdetails(self.flow) elif key == "z":