Merge branch 'master' of github.com:mitmproxy/mitmproxy

This commit is contained in:
Maximilian Hils 2015-03-30 03:49:59 +02:00
commit 5977e844e7

View File

@ -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,58 +472,6 @@ 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 == "e":
if self.tab_offset == TAB_REQ:
signals.status_prompt_onekey.send(
prompt = "Edit request",
keys = (
("query", "q"),
("path", "p"),
("url", "u"),
("header", "h"),
("form", "f"),
("raw body", "r"),
("method", "m"),
),
callback = self.edit
)
else:
signals.status_prompt_onekey.send(
prompt = "Edit response",
keys = (
("code", "c"),
("message", "m"),
("header", "h"),
("raw body", "r"),
),
callback = self.edit
)
key = None
elif key == "f":
signals.status_message.send(message="Loading all body data...")
self.state.add_flow_setting(
self.flow,
(self.tab_state, "fullcontents"),
True
)
signals.flow_change.send(self, flow = self.flow)
signals.status_message.send(message="")
elif key == "g":
if self.tab_offset == TAB_REQ:
scope = "q"
else:
scope = "s"
common.ask_copy_part(scope, self.flow, self.master, self.state)
elif key == "m":
p = list(contentview.view_prompts)
p.insert(0, ("Clear", "C"))
signals.status_prompt_onekey.send(
self,
prompt = "Display mode",
keys = p,
callback = self.change_this_display_mode
)
key = None
elif key == "p": elif key == "p":
self.view_prev_flow(self.flow) self.view_prev_flow(self.flow)
elif key == "r": elif key == "r":
@ -547,34 +492,97 @@ class FlowView(tabs.Tabs):
callback = self.master.save_one_flow, callback = self.master.save_one_flow,
args = (self.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 == "|": elif key == "|":
signals.status_prompt_path.send( signals.status_prompt_path.send(
prompt = "Send flow to script", prompt = "Send flow to script",
callback = self.master.run_script_once, callback = self.master.run_script_once,
args = (self.flow,) args = (self.flow,)
) )
elif key == "x":
signals.status_prompt_onekey.send( if not conn and key in "befgmxvz":
prompt = "Delete body", signals.status_message.send(
keys = ( message = "Tab to the request or response",
("completely", "c"), expire = 1
("mark as missing", "m"),
),
callback = self.delete_body
) )
key = None elif conn:
elif key == "z": if key == "b":
if conn: 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":
if self.tab_offset == TAB_REQ:
signals.status_prompt_onekey.send(
prompt = "Edit request",
keys = (
("query", "q"),
("path", "p"),
("url", "u"),
("header", "h"),
("form", "f"),
("raw body", "r"),
("method", "m"),
),
callback = self.edit
)
else:
signals.status_prompt_onekey.send(
prompt = "Edit response",
keys = (
("code", "c"),
("message", "m"),
("header", "h"),
("raw body", "r"),
),
callback = self.edit
)
key = None
elif key == "f":
signals.status_message.send(message="Loading all body data...")
self.state.add_flow_setting(
self.flow,
(self.tab_offset, "fullcontents"),
True
)
signals.flow_change.send(self, flow = self.flow)
signals.status_message.send(message="")
elif key == "g":
if self.tab_offset == TAB_REQ:
scope = "q"
else:
scope = "s"
common.ask_copy_part(scope, self.flow, self.master, self.state)
elif key == "m":
p = list(contentview.view_prompts)
p.insert(0, ("Clear", "C"))
signals.status_prompt_onekey.send(
self,
prompt = "Display mode",
keys = p,
callback = self.change_this_display_mode
)
key = None
elif key == "x":
signals.status_prompt_onekey.send(
prompt = "Delete body",
keys = (
("completely", "c"),
("mark as missing", "m"),
),
callback = self.delete_body
)
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":
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":
@ -593,6 +601,8 @@ class FlowView(tabs.Tabs):
args = (conn,) args = (conn,)
) )
signals.flow_change.send(self, flow = self.flow) signals.flow_change.send(self, flow = self.flow)
else:
return super(self.__class__, self).keypress(size, key)
else: else:
return super(self.__class__, self).keypress(size, key) return super(self.__class__, self).keypress(size, key)