aboutsummaryrefslogtreecommitdiffstats
path: root/libmproxy/console/connview.py
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2012-02-11 11:25:35 +1300
committerAldo Cortesi <aldo@nullcube.com>2012-02-11 11:25:35 +1300
commit586472e364c1fb411711979efa604f2a5128c40d (patch)
tree9bc21068549a90da5a379ac03bd239f1239de33b /libmproxy/console/connview.py
parentda1ccfddeb38c534e8d511c45980783af76716c2 (diff)
downloadmitmproxy-586472e364c1fb411711979efa604f2a5128c40d.tar.gz
mitmproxy-586472e364c1fb411711979efa604f2a5128c40d.tar.bz2
mitmproxy-586472e364c1fb411711979efa604f2a5128c40d.zip
Revamp the way request and response bodies are displayed.
Diffstat (limited to 'libmproxy/console/connview.py')
-rw-r--r--libmproxy/console/connview.py61
1 files changed, 40 insertions, 21 deletions
diff --git a/libmproxy/console/connview.py b/libmproxy/console/connview.py
index 1a5495db..7b9dcb87 100644
--- a/libmproxy/console/connview.py
+++ b/libmproxy/console/connview.py
@@ -160,14 +160,14 @@ class ConnectionView(common.WWrap):
]
def _view_conn_urlencoded(self, lines):
- kv = common.format_keyvals(
- [(k+":", v) for (k, v) in lines],
- key = "header",
- val = "text"
- )
- return [
- urwid.Text(("highlight", "URLencoded data:\n")),
- urwid.Text(kv)
+ return [
+ urwid.Text(
+ common.format_keyvals(
+ [(k+":", v) for (k, v) in lines],
+ key = "header",
+ val = "text"
+ )
+ )
]
def _find_pretty_view(self, content, hdrItems):
@@ -179,18 +179,18 @@ class ConnectionView(common.WWrap):
if ctype and flow.HDR_FORM_URLENCODED in ctype:
data = utils.urldecode(content)
if data:
- return self._view_conn_urlencoded(data)
+ return "URLEncoded form", self._view_conn_urlencoded(data)
if utils.isXML(content):
- return self._view_conn_xmlish(content)
+ return "Indented XML-ish", self._view_conn_xmlish(content)
elif ctype and "application/json" in ctype:
lines = utils.pretty_json(content)
if lines:
- return self._view_conn_json(lines)
+ return "JSON", self._view_conn_json(lines)
elif ctype and "multipart/form-data" in ctype:
boundary = ctype.split('boundary=')
if len(boundary) > 1:
- return self._view_conn_formdata(content, boundary[1].split(';')[0])
- return self._view_conn_raw(content)
+ return "FOrm data", self._view_conn_formdata(content, boundary[1].split(';')[0])
+ return "", self._view_conn_raw(content)
def _cached_conn_text(self, e, content, hdrItems, viewmode):
hdr = []
@@ -201,24 +201,43 @@ class ConnectionView(common.WWrap):
val = "text"
)
)
- hdr.append("\n")
-
txt = [urwid.Text(hdr)]
if content:
+ msg = ""
if viewmode == common.VIEW_BODY_HEX:
- txt.extend(self._view_conn_binary(content))
+ body = self._view_conn_binary(content)
elif viewmode == common.VIEW_BODY_PRETTY:
+ emsg = ""
if e:
decoded = encoding.decode(e, content)
if decoded:
content = decoded
if e and e != "identity":
- txt.append(
- urwid.Text(("highlight", "Decoded %s data:\n"%e))
- )
- txt.extend(self._find_pretty_view(content, hdrItems))
+ emsg = "[decoded %s]"%e
+ msg, body = self._find_pretty_view(content, hdrItems)
+ if emsg:
+ msg = emsg + " " + msg
else:
- txt.extend(self._view_conn_raw(content))
+ body = self._view_conn_raw(content)
+
+ title = urwid.AttrWrap(urwid.Columns([
+ urwid.Text(
+ [
+ ("statusbar", msg),
+ ]
+ ),
+ urwid.Text(
+ [
+ " ",
+ ('statusbar_text', "["),
+ ('statusbar_key', "m"),
+ ('statusbar_text', (":%s]"%common.BODY_VIEWS[self.master.state.view_body_mode])),
+ ],
+ align="right"
+ ),
+ ]), "statusbar")
+ txt.append(title)
+ txt.extend(body)
return urwid.ListBox(txt)
def _tab(self, content, active):