Add interface to mark content missing, and extend UI to indicate when content is missing.

This commit is contained in:
Aldo Cortesi 2012-05-16 18:16:44 +12:00
parent 0c2d894cea
commit b3901a7652
2 changed files with 37 additions and 4 deletions

View File

@ -15,7 +15,7 @@
import urwid import urwid
import urwid.util 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, resp_code = f.response.code if f.response else None,
) )
if f.response: 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( d.update(dict(
resp_code = f.response.code, resp_code = f.response.code,
resp_is_replay = f.response.is_replay(), resp_is_replay = f.response.is_replay(),
resp_acked = f.response.acked, 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"] t = f.response.headers["content-type"]
if t: if t:

View File

@ -68,6 +68,7 @@ def _mkhelp():
("v", "view body in external viewer"), ("v", "view body in external viewer"),
("w", "save all flows matching current limit"), ("w", "save all flows matching current limit"),
("W", "save this flow"), ("W", "save this flow"),
("x", "delete body"),
("X", "view flow details"), ("X", "view flow details"),
("z", "encode/decode a request/response"), ("z", "encode/decode a request/response"),
("tab", "toggle request/response view"), ("tab", "toggle request/response view"),
@ -153,14 +154,17 @@ class FlowView(common.WWrap):
key = "header", key = "header",
val = "text" val = "text"
) )
if conn.content: if conn.content is not None:
override = self.state.get_flow_setting( override = self.state.get_flow_setting(
self.flow, self.flow,
(self.state.view_flow_mode, "prettyview"), (self.state.view_flow_mode, "prettyview"),
) )
viewmode = self.state.default_body_view if override is None else override 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 = [ cols = [
urwid.Text( urwid.Text(
@ -184,6 +188,8 @@ class FlowView(common.WWrap):
title = urwid.AttrWrap(urwid.Columns(cols), "heading") title = urwid.AttrWrap(urwid.Columns(cols), "heading")
txt.append(title) txt.append(title)
txt.extend(body) txt.extend(body)
elif conn.content == flow.CONTENT_MISSING:
pass
return urwid.ListBox(txt) return urwid.ListBox(txt)
def _tab(self, content, attr): def _tab(self, content, attr):
@ -390,6 +396,17 @@ class FlowView(common.WWrap):
) )
self.master.refresh_flow(self.flow) 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): def keypress(self, size, key):
if key == " ": if key == " ":
self.view_next_flow(self.flow) self.view_next_flow(self.flow)
@ -523,6 +540,16 @@ class FlowView(common.WWrap):
"Send flow to script: ", self.state.last_script, "Send flow to script: ", self.state.last_script,
self.master.run_script_once, self.flow 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": elif key == "X":
self.master.view_flowdetails(self.flow) self.master.view_flowdetails(self.flow)
elif key == "z": elif key == "z":