mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-23 16:17:49 +00:00
Merge branch 'master' of github.com:mitmproxy/mitmproxy
This commit is contained in:
commit
5977e844e7
@ -67,10 +67,10 @@ def _mkhelp():
|
|||||||
("W", "save this flow"),
|
("W", "save this flow"),
|
||||||
("x", "delete body"),
|
("x", "delete body"),
|
||||||
("z", "encode/decode a request/response"),
|
("z", "encode/decode a request/response"),
|
||||||
("tab", "toggle request/response view"),
|
("tab", "next tab"),
|
||||||
("space", "next flow"),
|
("space", "next flow"),
|
||||||
("|", "run script on this flow"),
|
("|", "run script on this flow"),
|
||||||
("/", "search in response body (case sensitive)"),
|
("/", "search (case sensitive)"),
|
||||||
("n", "repeat search forward"),
|
("n", "repeat search forward"),
|
||||||
("N", "repeat search backwards"),
|
("N", "repeat search backwards"),
|
||||||
]
|
]
|
||||||
@ -367,25 +367,25 @@ class FlowView(tabs.Tabs):
|
|||||||
self.set_query, message
|
self.set_query, message
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
elif part == "u" and self.tab_offset == TAB_REQ:
|
elif part == "u":
|
||||||
signals.status_prompt.send(
|
signals.status_prompt.send(
|
||||||
prompt = "URL",
|
prompt = "URL",
|
||||||
text = message.url,
|
text = message.url,
|
||||||
callback = self.set_url
|
callback = self.set_url
|
||||||
)
|
)
|
||||||
elif part == "m" and self.tab_offset == TAB_REQ:
|
elif part == "m":
|
||||||
signals.status_prompt_onekey.send(
|
signals.status_prompt_onekey.send(
|
||||||
prompt = "Method",
|
prompt = "Method",
|
||||||
keys = common.METHOD_OPTIONS,
|
keys = common.METHOD_OPTIONS,
|
||||||
callback = self.edit_method
|
callback = self.edit_method
|
||||||
)
|
)
|
||||||
elif part == "c" and self.tab_offset == TAB_RESP:
|
elif part == "c":
|
||||||
signals.status_prompt.send(
|
signals.status_prompt.send(
|
||||||
prompt = "Code",
|
prompt = "Code",
|
||||||
text = str(message.code),
|
text = str(message.code),
|
||||||
callback = self.set_resp_code
|
callback = self.set_resp_code
|
||||||
)
|
)
|
||||||
elif part == "m" and self.tab_offset == TAB_RESP:
|
elif part == "m":
|
||||||
signals.status_prompt.send(
|
signals.status_prompt.send(
|
||||||
prompt = "Message",
|
prompt = "Message",
|
||||||
text = message.msg,
|
text = message.msg,
|
||||||
@ -441,8 +441,10 @@ class FlowView(tabs.Tabs):
|
|||||||
key = common.shortcuts(key)
|
key = common.shortcuts(key)
|
||||||
if self.tab_offset == TAB_REQ:
|
if self.tab_offset == TAB_REQ:
|
||||||
conn = self.flow.request
|
conn = self.flow.request
|
||||||
else:
|
elif self.tab_offset == TAB_RESP:
|
||||||
conn = self.flow.response
|
conn = self.flow.response
|
||||||
|
else:
|
||||||
|
conn = None
|
||||||
|
|
||||||
if key == "q":
|
if key == "q":
|
||||||
signals.pop_view_state.send(self)
|
signals.pop_view_state.send(self)
|
||||||
@ -456,11 +458,6 @@ class FlowView(tabs.Tabs):
|
|||||||
elif key == "A":
|
elif key == "A":
|
||||||
self.master.accept_all()
|
self.master.accept_all()
|
||||||
self.master.view_flow(self.flow)
|
self.master.view_flow(self.flow)
|
||||||
elif key == "b":
|
|
||||||
if self.tab_offset == TAB_REQ:
|
|
||||||
common.ask_save_body("q", self.master, self.state, self.flow)
|
|
||||||
else:
|
|
||||||
common.ask_save_body("s", self.master, self.state, self.flow)
|
|
||||||
elif key == "d":
|
elif key == "d":
|
||||||
if self.state.flow_count() == 1:
|
if self.state.flow_count() == 1:
|
||||||
self.master.view_flowlist()
|
self.master.view_flowlist()
|
||||||
@ -475,6 +472,44 @@ class FlowView(tabs.Tabs):
|
|||||||
f = self.master.duplicate_flow(self.flow)
|
f = self.master.duplicate_flow(self.flow)
|
||||||
self.master.view_flow(f)
|
self.master.view_flow(f)
|
||||||
signals.status_message.send(message="Duplicated.")
|
signals.status_message.send(message="Duplicated.")
|
||||||
|
elif key == "p":
|
||||||
|
self.view_prev_flow(self.flow)
|
||||||
|
elif key == "r":
|
||||||
|
r = self.master.replay_request(self.flow)
|
||||||
|
if r:
|
||||||
|
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
|
||||||
|
self.state.revert(self.flow)
|
||||||
|
signals.flow_change.send(self, flow = self.flow)
|
||||||
|
signals.status_message.send(message="Reverted.")
|
||||||
|
elif key == "W":
|
||||||
|
signals.status_prompt_path.send(
|
||||||
|
prompt = "Save this flow",
|
||||||
|
callback = self.master.save_one_flow,
|
||||||
|
args = (self.flow,)
|
||||||
|
)
|
||||||
|
elif key == "|":
|
||||||
|
signals.status_prompt_path.send(
|
||||||
|
prompt = "Send flow to script",
|
||||||
|
callback = self.master.run_script_once,
|
||||||
|
args = (self.flow,)
|
||||||
|
)
|
||||||
|
|
||||||
|
if not conn and key in "befgmxvz":
|
||||||
|
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.master, self.state, self.flow)
|
||||||
|
else:
|
||||||
|
common.ask_save_body("s", self.master, self.state, self.flow)
|
||||||
elif key == "e":
|
elif key == "e":
|
||||||
if self.tab_offset == TAB_REQ:
|
if self.tab_offset == TAB_REQ:
|
||||||
signals.status_prompt_onekey.send(
|
signals.status_prompt_onekey.send(
|
||||||
@ -506,7 +541,7 @@ class FlowView(tabs.Tabs):
|
|||||||
signals.status_message.send(message="Loading all body data...")
|
signals.status_message.send(message="Loading all body data...")
|
||||||
self.state.add_flow_setting(
|
self.state.add_flow_setting(
|
||||||
self.flow,
|
self.flow,
|
||||||
(self.tab_state, "fullcontents"),
|
(self.tab_offset, "fullcontents"),
|
||||||
True
|
True
|
||||||
)
|
)
|
||||||
signals.flow_change.send(self, flow = self.flow)
|
signals.flow_change.send(self, flow = self.flow)
|
||||||
@ -527,42 +562,6 @@ class FlowView(tabs.Tabs):
|
|||||||
callback = self.change_this_display_mode
|
callback = self.change_this_display_mode
|
||||||
)
|
)
|
||||||
key = None
|
key = None
|
||||||
elif key == "p":
|
|
||||||
self.view_prev_flow(self.flow)
|
|
||||||
elif key == "r":
|
|
||||||
r = self.master.replay_request(self.flow)
|
|
||||||
if r:
|
|
||||||
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
|
|
||||||
self.state.revert(self.flow)
|
|
||||||
signals.flow_change.send(self, flow = self.flow)
|
|
||||||
signals.status_message.send(message="Reverted.")
|
|
||||||
elif key == "W":
|
|
||||||
signals.status_prompt_path.send(
|
|
||||||
prompt = "Save this flow",
|
|
||||||
callback = self.master.save_one_flow,
|
|
||||||
args = (self.flow,)
|
|
||||||
)
|
|
||||||
elif key == "v":
|
|
||||||
if conn and conn.content:
|
|
||||||
t = conn.headers["content-type"] or [None]
|
|
||||||
t = t[0]
|
|
||||||
if os.environ.has_key("EDITOR") or os.environ.has_key("PAGER"):
|
|
||||||
self.master.spawn_external_viewer(conn.content, t)
|
|
||||||
else:
|
|
||||||
signals.status_message.send(
|
|
||||||
message = "Error! Set $EDITOR or $PAGER."
|
|
||||||
)
|
|
||||||
elif key == "|":
|
|
||||||
signals.status_prompt_path.send(
|
|
||||||
prompt = "Send flow to script",
|
|
||||||
callback = self.master.run_script_once,
|
|
||||||
args = (self.flow,)
|
|
||||||
)
|
|
||||||
elif key == "x":
|
elif key == "x":
|
||||||
signals.status_prompt_onekey.send(
|
signals.status_prompt_onekey.send(
|
||||||
prompt = "Delete body",
|
prompt = "Delete body",
|
||||||
@ -573,8 +572,17 @@ class FlowView(tabs.Tabs):
|
|||||||
callback = self.delete_body
|
callback = self.delete_body
|
||||||
)
|
)
|
||||||
key = None
|
key = None
|
||||||
|
elif key == "v":
|
||||||
|
if conn.content:
|
||||||
|
t = conn.headers["content-type"] or [None]
|
||||||
|
t = t[0]
|
||||||
|
if os.environ.has_key("EDITOR") or os.environ.has_key("PAGER"):
|
||||||
|
self.master.spawn_external_viewer(conn.content, t)
|
||||||
|
else:
|
||||||
|
signals.status_message.send(
|
||||||
|
message = "Error! Set $EDITOR or $PAGER."
|
||||||
|
)
|
||||||
elif key == "z":
|
elif key == "z":
|
||||||
if conn:
|
|
||||||
self.flow.backup()
|
self.flow.backup()
|
||||||
e = conn.headers.get_first("content-encoding", "identity")
|
e = conn.headers.get_first("content-encoding", "identity")
|
||||||
if e != "identity":
|
if e != "identity":
|
||||||
@ -595,6 +603,8 @@ class FlowView(tabs.Tabs):
|
|||||||
signals.flow_change.send(self, flow = self.flow)
|
signals.flow_change.send(self, flow = self.flow)
|
||||||
else:
|
else:
|
||||||
return super(self.__class__, self).keypress(size, key)
|
return super(self.__class__, self).keypress(size, key)
|
||||||
|
else:
|
||||||
|
return super(self.__class__, self).keypress(size, key)
|
||||||
|
|
||||||
def encode_callback(self, key, conn):
|
def encode_callback(self, key, conn):
|
||||||
encoding_map = {
|
encoding_map = {
|
||||||
|
Loading…
Reference in New Issue
Block a user