aboutsummaryrefslogtreecommitdiffstats
path: root/libmproxy/console/flowview.py
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2012-03-20 11:11:53 +1300
committerAldo Cortesi <aldo@nullcube.com>2012-03-20 11:11:53 +1300
commit1441fade907142598e26ef7c4850700d936988a9 (patch)
tree8d9df63df56bd101cca183b530f476ac0e481b24 /libmproxy/console/flowview.py
parent215383554525535816accdd8580d06b9e4cf7565 (diff)
downloadmitmproxy-1441fade907142598e26ef7c4850700d936988a9.tar.gz
mitmproxy-1441fade907142598e26ef7c4850700d936988a9.tar.bz2
mitmproxy-1441fade907142598e26ef7c4850700d936988a9.zip
More work on pretty view forcing.
- Make this setting apply only to the currently viewed flow. I think it's more likely that this is the behaviour the user will want, rather than globally setting the pretty type. - Update help.
Diffstat (limited to 'libmproxy/console/flowview.py')
-rw-r--r--libmproxy/console/flowview.py30
1 files changed, 21 insertions, 9 deletions
diff --git a/libmproxy/console/flowview.py b/libmproxy/console/flowview.py
index 4c4cc86b..112548e9 100644
--- a/libmproxy/console/flowview.py
+++ b/libmproxy/console/flowview.py
@@ -48,14 +48,14 @@ def _mkhelp():
[("text", ": automatic detection")]
),
(None,
- common.highlight_key("html", "h") +
- [("text", ": format as HTML")]
- ),
- (None,
common.highlight_key("json", "j") +
[("text", ": format as JSON")]
),
(None,
+ common.highlight_key("urlencoded", "u") +
+ [("text", ": format as URL-encoded data")]
+ ),
+ (None,
common.highlight_key("xml", "x") +
[("text", ": format as XML")]
),
@@ -75,7 +75,7 @@ help_context = _mkhelp()
VIEW_CUTOFF = 1024*100
-class ConnectionViewHeader(common.WWrap):
+class FlowViewHeader(common.WWrap):
def __init__(self, master, f):
self.master, self.flow = master, f
self.w = common.format_flow(f, False, extended=True, padding=0)
@@ -92,7 +92,7 @@ class CallbackCache:
cache = CallbackCache()
-class ConnectionView(common.WWrap):
+class FlowView(common.WWrap):
REQ = 0
RESP = 1
method_options = [
@@ -107,6 +107,7 @@ class ConnectionView(common.WWrap):
]
def __init__(self, master, state, flow):
self.master, self.state, self.flow = master, state, flow
+ self.view_body_pretty_type = common.VIEW_BODY_PRETTY_TYPE_AUTO
if self.state.view_flow_mode == common.VIEW_FLOW_RESPONSE and flow.response:
self.view_response()
else:
@@ -327,7 +328,7 @@ class ConnectionView(common.WWrap):
body = self._conn_text(
self.flow.request,
self.state.view_body_mode,
- self.state.view_body_pretty_type
+ self.view_body_pretty_type
)
self.w = self.wrap_body(common.VIEW_FLOW_REQUEST, body)
self.master.statusbar.redraw()
@@ -338,7 +339,7 @@ class ConnectionView(common.WWrap):
body = self._conn_text(
self.flow.response,
self.state.view_body_mode,
- self.state.view_body_pretty_type
+ self.view_body_pretty_type
)
else:
body = urwid.ListBox(
@@ -491,6 +492,17 @@ class ConnectionView(common.WWrap):
def view_prev_flow(self, flow):
return self._view_nextprev_flow("prev", flow)
+ def change_pretty_type(self, t):
+ if t == "a":
+ self.view_body_pretty_type = common.VIEW_BODY_PRETTY_TYPE_AUTO
+ elif t == "j":
+ self.view_body_pretty_type = common.VIEW_BODY_PRETTY_TYPE_JSON
+ elif t == "u":
+ self.view_body_pretty_type = common.VIEW_BODY_PRETTY_TYPE_URLENCODED
+ elif t == "x":
+ self.view_body_pretty_type = common.VIEW_BODY_PRETTY_TYPE_XML
+ self.master.refresh_flow(self.flow)
+
def keypress(self, size, key):
if key == " ":
self.view_next_flow(self.flow)
@@ -587,7 +599,7 @@ class ConnectionView(common.WWrap):
("urlencoded", "u"),
("xmlish", "x"),
),
- self.master.change_pretty_type
+ self.change_pretty_type
)
key = None
elif key == "V":