diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2012-04-02 09:30:38 +1200 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2012-04-02 09:30:38 +1200 |
commit | 7fef0ecdf5618d06e78ee8f833525d7784234df8 (patch) | |
tree | f112717d6f42194e5af26b645c8fe7007d5e3a0a /libmproxy/console/flowview.py | |
parent | 35f4a1c424907d296a2ee0e852107542fcf8ac0d (diff) | |
download | mitmproxy-7fef0ecdf5618d06e78ee8f833525d7784234df8.tar.gz mitmproxy-7fef0ecdf5618d06e78ee8f833525d7784234df8.tar.bz2 mitmproxy-7fef0ecdf5618d06e78ee8f833525d7784234df8.zip |
Make "T" pretty view over-ride persistent when switching between flows.
We do this by adding a flow settings mechanism to ConsoleState. This is pretty
rough at the moment and should become more sophisticated as needed.
Diffstat (limited to 'libmproxy/console/flowview.py')
-rw-r--r-- | libmproxy/console/flowview.py | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/libmproxy/console/flowview.py b/libmproxy/console/flowview.py index da89f763..bbf3a89a 100644 --- a/libmproxy/console/flowview.py +++ b/libmproxy/console/flowview.py @@ -123,7 +123,6 @@ class FlowView(common.WWrap): ] def __init__(self, master, state, flow): self.master, self.state, self.flow = master, state, flow - self.view_body_pretty_type = contentview.VIEW_CONTENT_PRETTY_TYPE_AUTO if self.state.view_flow_mode == common.VIEW_FLOW_RESPONSE: self.view_response() else: @@ -205,7 +204,11 @@ class FlowView(common.WWrap): body = self._conn_text( self.flow.request, self.state.view_body_mode, - self.view_body_pretty_type + self.state.get_flow_setting( + self.flow, + (common.VIEW_FLOW_REQUEST, "prettyview"), + contentview.VIEW_CONTENT_PRETTY_TYPE_AUTO + ) ) self.w = self.wrap_body(common.VIEW_FLOW_REQUEST, body) self.master.statusbar.redraw() @@ -216,7 +219,11 @@ class FlowView(common.WWrap): body = self._conn_text( self.flow.response, self.state.view_body_mode, - self.view_body_pretty_type + self.state.get_flow_setting( + self.flow, + (common.VIEW_FLOW_RESPONSE, "prettyview"), + contentview.VIEW_CONTENT_PRETTY_TYPE_AUTO + ) ) else: body = urwid.ListBox( @@ -371,18 +378,19 @@ class FlowView(common.WWrap): return self._view_nextprev_flow("prev", flow) def change_pretty_type(self, t): - if t == "a": - self.view_body_pretty_type = contentview.VIEW_CONTENT_PRETTY_TYPE_AUTO - elif t == "i": - self.view_body_pretty_type = contentview.VIEW_CONTENT_PRETTY_TYPE_IMAGE - elif t == "j": - self.view_body_pretty_type = contentview.VIEW_CONTENT_PRETTY_TYPE_JAVASCRIPT - elif t == "s": - self.view_body_pretty_type = contentview.VIEW_CONTENT_PRETTY_TYPE_JSON - elif t == "u": - self.view_body_pretty_type = contentview.VIEW_CONTENT_PRETTY_TYPE_URLENCODED - elif t == "x": - self.view_body_pretty_type = contentview.VIEW_CONTENT_PRETTY_TYPE_XML + d = { + "a": contentview.VIEW_CONTENT_PRETTY_TYPE_AUTO, + "i": contentview.VIEW_CONTENT_PRETTY_TYPE_IMAGE, + "j": contentview.VIEW_CONTENT_PRETTY_TYPE_JAVASCRIPT, + "s": contentview.VIEW_CONTENT_PRETTY_TYPE_JSON, + "u": contentview.VIEW_CONTENT_PRETTY_TYPE_URLENCODED, + "x": contentview.VIEW_CONTENT_PRETTY_TYPE_XML, + } + self.state.add_flow_setting( + self.flow, + (self.state.view_flow_mode, "prettyview"), + d.get(t) + ) self.master.refresh_flow(self.flow) def keypress(self, size, key): |