mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-23 00:01:36 +00:00
parent
a87d089561
commit
4d042ec543
@ -39,7 +39,7 @@ def _mkhelp():
|
||||
("d", "delete flow"),
|
||||
("e", "edit request/response"),
|
||||
("f", "load full body data"),
|
||||
("m", "change body display mode for this entity"),
|
||||
("m", "change body display mode for this entity\n(default mode can be changed in the options)"),
|
||||
(None,
|
||||
common.highlight_key("automatic", "a") +
|
||||
[("text", ": automatic detection")]
|
||||
@ -76,7 +76,6 @@ def _mkhelp():
|
||||
common.highlight_key("xml", "x") +
|
||||
[("text", ": XML")]
|
||||
),
|
||||
("M", "change default body display mode"),
|
||||
("E", "export flow to file"),
|
||||
("r", "replay request"),
|
||||
("V", "revert changes to request"),
|
||||
@ -137,7 +136,7 @@ class FlowView(tabs.Tabs):
|
||||
|
||||
def __init__(self, master, state, flow, tab_offset):
|
||||
self.master, self.state, self.flow = master, state, flow
|
||||
tabs.Tabs.__init__(self,
|
||||
super(FlowView, self).__init__(
|
||||
[
|
||||
(self.tab_request, self.view_request),
|
||||
(self.tab_response, self.view_response),
|
||||
@ -145,6 +144,7 @@ class FlowView(tabs.Tabs):
|
||||
],
|
||||
tab_offset
|
||||
)
|
||||
|
||||
self.show()
|
||||
self.last_displayed_body = None
|
||||
signals.flow_change.connect(self.sig_flow_change)
|
||||
@ -404,7 +404,7 @@ class FlowView(tabs.Tabs):
|
||||
if not self.flow.response:
|
||||
self.flow.response = models.HTTPResponse(
|
||||
self.flow.request.http_version,
|
||||
200, "OK", Headers(), ""
|
||||
200, b"OK", Headers(), b""
|
||||
)
|
||||
self.flow.response.reply = controller.DummyReply()
|
||||
message = self.flow.response
|
||||
@ -533,24 +533,23 @@ class FlowView(tabs.Tabs):
|
||||
signals.flow_change.send(self, flow = self.flow)
|
||||
|
||||
def keypress(self, size, key):
|
||||
key = super(self.__class__, self).keypress(size, key)
|
||||
|
||||
if key == " ":
|
||||
self.view_next_flow(self.flow)
|
||||
return
|
||||
|
||||
key = common.shortcuts(key)
|
||||
|
||||
conn = None # type: Optional[Union[models.HTTPRequest, models.HTTPResponse]]
|
||||
if self.tab_offset == TAB_REQ:
|
||||
conn = self.flow.request
|
||||
elif self.tab_offset == TAB_RESP:
|
||||
conn = self.flow.response
|
||||
else:
|
||||
conn = None
|
||||
|
||||
key = super(self.__class__, self).keypress(size, key)
|
||||
|
||||
# Special case: Space moves over to the next flow.
|
||||
# We need to catch that before applying common.shortcuts()
|
||||
if key == " ":
|
||||
self.view_next_flow(self.flow)
|
||||
return
|
||||
|
||||
key = common.shortcuts(key)
|
||||
if key in ("up", "down", "page up", "page down"):
|
||||
# Why doesn't this just work??
|
||||
# Pass scroll events to the wrapped widget
|
||||
self._w.keypress(size, key)
|
||||
elif key == "a":
|
||||
self.flow.accept_intercept(self.master)
|
||||
@ -582,12 +581,12 @@ class FlowView(tabs.Tabs):
|
||||
signals.status_message.send(message=r)
|
||||
signals.flow_change.send(self, flow = self.flow)
|
||||
elif key == "V":
|
||||
if not self.flow.modified():
|
||||
signals.status_message.send(message="Flow not modified.")
|
||||
return
|
||||
if self.flow.modified():
|
||||
self.state.revert(self.flow)
|
||||
signals.flow_change.send(self, flow = self.flow)
|
||||
signals.status_message.send(message="Reverted.")
|
||||
else:
|
||||
signals.status_message.send(message="Flow not modified.")
|
||||
elif key == "W":
|
||||
signals.status_prompt_path.send(
|
||||
prompt = "Save this flow",
|
||||
@ -600,27 +599,11 @@ class FlowView(tabs.Tabs):
|
||||
callback = self.master.run_script_once,
|
||||
args = (self.flow,)
|
||||
)
|
||||
|
||||
if not conn and key in set(list("befgmxvzEC")):
|
||||
signals.status_message.send(
|
||||
message = "Tab to the request or response",
|
||||
expire = 1
|
||||
)
|
||||
elif conn:
|
||||
if key == "b":
|
||||
if self.tab_offset == TAB_REQ:
|
||||
common.ask_save_body(
|
||||
"q", self.flow
|
||||
)
|
||||
else:
|
||||
common.ask_save_body(
|
||||
"s", self.flow
|
||||
)
|
||||
elif key == "e":
|
||||
if self.tab_offset == TAB_REQ:
|
||||
signals.status_prompt_onekey.send(
|
||||
prompt = "Edit request",
|
||||
keys = (
|
||||
prompt="Edit request",
|
||||
keys=(
|
||||
("cookies", "c"),
|
||||
("query", "q"),
|
||||
("path", "p"),
|
||||
@ -630,21 +613,36 @@ class FlowView(tabs.Tabs):
|
||||
("raw body", "r"),
|
||||
("method", "m"),
|
||||
),
|
||||
callback = self.edit
|
||||
callback=self.edit
|
||||
)
|
||||
else:
|
||||
elif self.tab_offset == TAB_RESP:
|
||||
signals.status_prompt_onekey.send(
|
||||
prompt = "Edit response",
|
||||
keys = (
|
||||
prompt="Edit response",
|
||||
keys=(
|
||||
("cookies", "c"),
|
||||
("code", "o"),
|
||||
("message", "m"),
|
||||
("header", "h"),
|
||||
("raw body", "r"),
|
||||
),
|
||||
callback = self.edit
|
||||
callback=self.edit
|
||||
)
|
||||
key = None
|
||||
else:
|
||||
signals.status_message.send(
|
||||
message="Tab to the request or response",
|
||||
expire=1
|
||||
)
|
||||
elif key in "bfgmxvzEC" and not conn:
|
||||
signals.status_message.send(
|
||||
message = "Tab to the request or response",
|
||||
expire = 1
|
||||
)
|
||||
return
|
||||
elif key == "b":
|
||||
if self.tab_offset == TAB_REQ:
|
||||
common.ask_save_body("q", self.flow)
|
||||
else:
|
||||
common.ask_save_body("s", self.flow)
|
||||
elif key == "f":
|
||||
signals.status_message.send(message="Loading all body data...")
|
||||
self.state.add_flow_setting(
|
||||
@ -663,7 +661,6 @@ class FlowView(tabs.Tabs):
|
||||
keys = p,
|
||||
callback = self.change_this_display_mode
|
||||
)
|
||||
key = None
|
||||
elif key == "E":
|
||||
if self.tab_offset == TAB_REQ:
|
||||
scope = "q"
|
||||
@ -721,6 +718,8 @@ class FlowView(tabs.Tabs):
|
||||
args = (conn,)
|
||||
)
|
||||
signals.flow_change.send(self, flow = self.flow)
|
||||
else:
|
||||
# Key is not handled here.
|
||||
return key
|
||||
|
||||
def encode_callback(self, key, conn):
|
||||
|
@ -25,7 +25,7 @@ class Tab(urwid.WidgetWrap):
|
||||
class Tabs(urwid.WidgetWrap):
|
||||
|
||||
def __init__(self, tabs, tab_offset=0):
|
||||
urwid.WidgetWrap.__init__(self, "")
|
||||
super(Tabs, self).__init__("")
|
||||
self.tab_offset = tab_offset
|
||||
self.tabs = tabs
|
||||
self.show()
|
||||
|
Loading…
Reference in New Issue
Block a user