mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2025-02-04 01:05:36 +00:00
Truncate URLs in console
This commit is contained in:
parent
cacee3871c
commit
22283dd373
@ -32,6 +32,8 @@ METHOD_OPTIONS = [
|
||||
("edit raw", "e"),
|
||||
]
|
||||
|
||||
MAX_URL_LEN = 200
|
||||
|
||||
|
||||
def is_keypress(k):
|
||||
"""
|
||||
@ -328,7 +330,7 @@ def export_to_clip_or_file(key, scope, flow, writer):
|
||||
flowcache = utils.LRUCache(800)
|
||||
|
||||
|
||||
def raw_format_flow(f, focus, extended):
|
||||
def raw_format_flow(f, focus, extended, short_urls):
|
||||
f = dict(f)
|
||||
pile = []
|
||||
req = []
|
||||
@ -359,6 +361,11 @@ def raw_format_flow(f, focus, extended):
|
||||
uc = "title"
|
||||
|
||||
url = f["req_url"]
|
||||
|
||||
# TODO: Add a configuration setting that disables this behaviour?
|
||||
if short_urls and len(url) > MAX_URL_LEN:
|
||||
url = url[:MAX_URL_LEN] + "..."
|
||||
|
||||
if f["req_http_version"] not in ("HTTP/1.0", "HTTP/1.1"):
|
||||
url += " " + f["req_http_version"]
|
||||
req.append(
|
||||
@ -410,7 +417,7 @@ def raw_format_flow(f, focus, extended):
|
||||
return urwid.Pile(pile)
|
||||
|
||||
|
||||
def format_flow(f, focus, extended=False, hostheader=False):
|
||||
def format_flow(f, focus, extended=False, hostheader=False, short_urls=True):
|
||||
d = dict(
|
||||
intercepted = f.intercepted,
|
||||
acked = f.reply.state == "committed",
|
||||
@ -451,5 +458,8 @@ def format_flow(f, focus, extended=False, hostheader=False):
|
||||
d["resp_ctype"] = ""
|
||||
return flowcache.get(
|
||||
raw_format_flow,
|
||||
tuple(sorted(d.items())), focus, extended
|
||||
tuple(sorted(d.items())),
|
||||
focus,
|
||||
extended,
|
||||
short_urls,
|
||||
)
|
||||
|
@ -108,6 +108,7 @@ class FlowViewHeader(urwid.WidgetWrap):
|
||||
f,
|
||||
False,
|
||||
extended=True,
|
||||
short_urls=False,
|
||||
hostheader=self.master.options.showhost
|
||||
)
|
||||
signals.flow_change.connect(self.sig_flow_change)
|
||||
@ -118,6 +119,7 @@ class FlowViewHeader(urwid.WidgetWrap):
|
||||
flow,
|
||||
False,
|
||||
extended=True,
|
||||
short_urls=False,
|
||||
hostheader=self.master.options.showhost
|
||||
)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user