mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-27 02:24:18 +00:00
Formatting and whitespace
This commit is contained in:
parent
468cc81c8a
commit
87a3c71041
@ -41,6 +41,8 @@ def highlight_key(s, k):
|
|||||||
|
|
||||||
|
|
||||||
KEY_MAX = 30
|
KEY_MAX = 30
|
||||||
|
|
||||||
|
|
||||||
def format_keyvals(lst, key="key", val="text", indent=0):
|
def format_keyvals(lst, key="key", val="text", indent=0):
|
||||||
"""
|
"""
|
||||||
Format a list of (key, value) tuples.
|
Format a list of (key, value) tuples.
|
||||||
@ -103,10 +105,8 @@ else:
|
|||||||
SYMBOL_RETURN = u"<-"
|
SYMBOL_RETURN = u"<-"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def raw_format_flow(f, focus, extended, padding):
|
def raw_format_flow(f, focus, extended, padding):
|
||||||
f = dict(f)
|
f = dict(f)
|
||||||
|
|
||||||
pile = []
|
pile = []
|
||||||
req = []
|
req = []
|
||||||
if extended:
|
if extended:
|
||||||
@ -348,7 +348,6 @@ def format_flow(f, focus, extended=False, hostheader=False, padding=2):
|
|||||||
duration = 0
|
duration = 0
|
||||||
if f.response.timestamp_end and f.request.timestamp_start:
|
if f.response.timestamp_end and f.request.timestamp_start:
|
||||||
duration = f.response.timestamp_end - f.request.timestamp_start
|
duration = f.response.timestamp_end - f.request.timestamp_start
|
||||||
size = f.response.size()
|
|
||||||
roundtrip = utils.pretty_duration(duration)
|
roundtrip = utils.pretty_duration(duration)
|
||||||
|
|
||||||
d.update(dict(
|
d.update(dict(
|
||||||
@ -362,7 +361,9 @@ def format_flow(f, focus, extended=False, hostheader=False, padding=2):
|
|||||||
d["resp_ctype"] = t[0].split(";")[0]
|
d["resp_ctype"] = t[0].split(";")[0]
|
||||||
else:
|
else:
|
||||||
d["resp_ctype"] = ""
|
d["resp_ctype"] = ""
|
||||||
return flowcache.format_flow(tuple(sorted(d.items())), focus, extended, padding)
|
return flowcache.format_flow(
|
||||||
|
tuple(sorted(d.items())), focus, extended, padding
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def int_version(v):
|
def int_version(v):
|
||||||
@ -380,8 +381,8 @@ class WWrap(urwid.WidgetWrap):
|
|||||||
if int_version(urwid.__version__) >= 990:
|
if int_version(urwid.__version__) >= 990:
|
||||||
def set_w(self, x):
|
def set_w(self, x):
|
||||||
self._w = x
|
self._w = x
|
||||||
|
|
||||||
def get_w(self):
|
def get_w(self):
|
||||||
return self._w
|
return self._w
|
||||||
|
|
||||||
w = property(get_w, set_w)
|
w = property(get_w, set_w)
|
||||||
|
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ import urwid
|
|||||||
from netlib import http
|
from netlib import http
|
||||||
from . import common
|
from . import common
|
||||||
|
|
||||||
|
|
||||||
def _mkhelp():
|
def _mkhelp():
|
||||||
text = []
|
text = []
|
||||||
keys = [
|
keys = [
|
||||||
@ -35,6 +36,7 @@ footer = [
|
|||||||
('heading_key', "?"), ":help ",
|
('heading_key', "?"), ":help ",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
class EventListBox(urwid.ListBox):
|
class EventListBox(urwid.ListBox):
|
||||||
def __init__(self, master):
|
def __init__(self, master):
|
||||||
self.master = master
|
self.master = master
|
||||||
@ -60,7 +62,10 @@ class BodyPile(urwid.Pile):
|
|||||||
self,
|
self,
|
||||||
[
|
[
|
||||||
FlowListBox(master),
|
FlowListBox(master),
|
||||||
urwid.Frame(EventListBox(master), header = self.inactive_header)
|
urwid.Frame(
|
||||||
|
EventListBox(master),
|
||||||
|
header = self.inactive_header
|
||||||
|
)
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
self.master = master
|
self.master = master
|
||||||
@ -95,7 +100,11 @@ class ConnectionItem(common.WWrap):
|
|||||||
common.WWrap.__init__(self, w)
|
common.WWrap.__init__(self, w)
|
||||||
|
|
||||||
def get_text(self):
|
def get_text(self):
|
||||||
return common.format_flow(self.flow, self.f, hostheader=self.master.showhost)
|
return common.format_flow(
|
||||||
|
self.flow,
|
||||||
|
self.f,
|
||||||
|
hostheader = self.master.showhost
|
||||||
|
)
|
||||||
|
|
||||||
def selectable(self):
|
def selectable(self):
|
||||||
return True
|
return True
|
||||||
@ -125,7 +134,8 @@ class ConnectionItem(common.WWrap):
|
|||||||
[i.copy() for i in self.master.state.view],
|
[i.copy() for i in self.master.state.view],
|
||||||
self.master.killextra, self.master.rheaders,
|
self.master.killextra, self.master.rheaders,
|
||||||
False, self.master.nopop,
|
False, self.master.nopop,
|
||||||
self.master.options.replay_ignore_params, self.master.options.replay_ignore_content,
|
self.master.options.replay_ignore_params,
|
||||||
|
self.master.options.replay_ignore_content,
|
||||||
self.master.options.replay_ignore_payload_params
|
self.master.options.replay_ignore_payload_params
|
||||||
)
|
)
|
||||||
elif k == "t":
|
elif k == "t":
|
||||||
@ -133,7 +143,8 @@ class ConnectionItem(common.WWrap):
|
|||||||
[self.flow.copy()],
|
[self.flow.copy()],
|
||||||
self.master.killextra, self.master.rheaders,
|
self.master.killextra, self.master.rheaders,
|
||||||
False, self.master.nopop,
|
False, self.master.nopop,
|
||||||
self.master.options.replay_ignore_params, self.master.options.replay_ignore_content,
|
self.master.options.replay_ignore_params,
|
||||||
|
self.master.options.replay_ignore_content,
|
||||||
self.master.options.replay_ignore_payload_params
|
self.master.options.replay_ignore_payload_params
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
@ -262,7 +273,12 @@ class FlowListBox(urwid.ListBox):
|
|||||||
self.get_url(method)
|
self.get_url(method)
|
||||||
|
|
||||||
def get_url(self, method):
|
def get_url(self, method):
|
||||||
self.master.prompt("URL:", "http://www.example.com/", self.new_request, method)
|
self.master.prompt(
|
||||||
|
"URL:",
|
||||||
|
"http://www.example.com/",
|
||||||
|
self.new_request,
|
||||||
|
method
|
||||||
|
)
|
||||||
|
|
||||||
def new_request(self, url, method):
|
def new_request(self, url, method):
|
||||||
parts = http.parse_url(str(url))
|
parts = http.parse_url(str(url))
|
||||||
@ -283,7 +299,11 @@ class FlowListBox(urwid.ListBox):
|
|||||||
elif key == "e":
|
elif key == "e":
|
||||||
self.master.toggle_eventlog()
|
self.master.toggle_eventlog()
|
||||||
elif key == "l":
|
elif key == "l":
|
||||||
self.master.prompt("Limit: ", self.master.state.limit_txt, self.master.set_limit)
|
self.master.prompt(
|
||||||
|
"Limit: ",
|
||||||
|
self.master.state.limit_txt,
|
||||||
|
self.master.set_limit
|
||||||
|
)
|
||||||
elif key == "L":
|
elif key == "L":
|
||||||
self.master.path_prompt(
|
self.master.path_prompt(
|
||||||
"Load flows: ",
|
"Load flows: ",
|
||||||
@ -291,7 +311,11 @@ class FlowListBox(urwid.ListBox):
|
|||||||
self.master.load_flows_callback
|
self.master.load_flows_callback
|
||||||
)
|
)
|
||||||
elif key == "n":
|
elif key == "n":
|
||||||
self.master.prompt_onekey("Method", common.METHOD_OPTIONS, self.get_method)
|
self.master.prompt_onekey(
|
||||||
|
"Method",
|
||||||
|
common.METHOD_OPTIONS,
|
||||||
|
self.get_method
|
||||||
|
)
|
||||||
elif key == "F":
|
elif key == "F":
|
||||||
self.master.toggle_follow_flows()
|
self.master.toggle_follow_flows()
|
||||||
elif key == "W":
|
elif key == "W":
|
||||||
|
Loading…
Reference in New Issue
Block a user