mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-26 18:18:25 +00:00
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.
This commit is contained in:
parent
2153835545
commit
1441fade90
@ -232,7 +232,6 @@ class ConsoleState(flow.State):
|
||||
flow.State.__init__(self)
|
||||
self.focus = None
|
||||
self.view_body_mode = common.VIEW_BODY_PRETTY
|
||||
self.view_body_pretty_type = common.VIEW_BODY_PRETTY_TYPE_AUTO
|
||||
self.view_flow_mode = common.VIEW_FLOW_REQUEST
|
||||
self.last_script = ""
|
||||
self.last_saveload = ""
|
||||
@ -571,8 +570,8 @@ class ConsoleMaster(flow.FlowMaster):
|
||||
self.help_context = flowlist.help_context
|
||||
|
||||
def view_flow(self, flow):
|
||||
self.body = flowview.ConnectionView(self, self.state, flow)
|
||||
self.header = flowview.ConnectionViewHeader(self, flow)
|
||||
self.body = flowview.FlowView(self, self.state, flow)
|
||||
self.header = flowview.FlowViewHeader(self, flow)
|
||||
self.statusbar = StatusBar(self, self.footer_text_flowview)
|
||||
self.currentflow = flow
|
||||
|
||||
@ -698,17 +697,6 @@ class ConsoleMaster(flow.FlowMaster):
|
||||
self.state.view_body_mode = common.VIEW_BODY_PRETTY
|
||||
self.refresh_flow(self.currentflow)
|
||||
|
||||
def change_pretty_type(self, t):
|
||||
if t == "a":
|
||||
self.state.view_body_pretty_type = common.VIEW_BODY_PRETTY_TYPE_AUTO
|
||||
elif t == "j":
|
||||
self.state.view_body_pretty_type = common.VIEW_BODY_PRETTY_TYPE_JSON
|
||||
elif t == "u":
|
||||
self.state.view_body_pretty_type = common.VIEW_BODY_PRETTY_TYPE_URLENCODED
|
||||
elif t == "x":
|
||||
self.state.view_body_pretty_type = common.VIEW_BODY_PRETTY_TYPE_XML
|
||||
self.refresh_flow(self.currentflow)
|
||||
|
||||
def drawscreen(self):
|
||||
size = self.ui.get_cols_rows()
|
||||
canvas = self.view.render(size, focus=1)
|
||||
|
@ -47,14 +47,14 @@ def _mkhelp():
|
||||
common.highlight_key("automatic", "a") +
|
||||
[("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":
|
||||
|
Loading…
Reference in New Issue
Block a user