mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-27 02:24:18 +00:00
Use unicode elipsis & make extra params a part of dict
This commit is contained in:
parent
41e4526a33
commit
7b5d5d3a54
@ -1,3 +1,5 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
from __future__ import absolute_import, print_function, division
|
from __future__ import absolute_import, print_function, division
|
||||||
|
|
||||||
import os
|
import os
|
||||||
@ -328,11 +330,11 @@ def export_to_clip_or_file(key, scope, flow, writer):
|
|||||||
flowcache = utils.LRUCache(800)
|
flowcache = utils.LRUCache(800)
|
||||||
|
|
||||||
|
|
||||||
def raw_format_flow(f, focus, extended, truncate_urls):
|
def raw_format_flow(f):
|
||||||
f = dict(f)
|
f = dict(f)
|
||||||
pile = []
|
pile = []
|
||||||
req = []
|
req = []
|
||||||
if extended:
|
if f["extended"]:
|
||||||
req.append(
|
req.append(
|
||||||
fcol(
|
fcol(
|
||||||
human.format_timestamp(f["req_timestamp"]),
|
human.format_timestamp(f["req_timestamp"]),
|
||||||
@ -340,7 +342,7 @@ def raw_format_flow(f, focus, extended, truncate_urls):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
req.append(fcol(">>" if focus else " ", "focus"))
|
req.append(fcol(">>" if f["focus"] else " ", "focus"))
|
||||||
|
|
||||||
if f["marked"]:
|
if f["marked"]:
|
||||||
req.append(fcol(SYMBOL_MARK, "mark"))
|
req.append(fcol(SYMBOL_MARK, "mark"))
|
||||||
@ -360,9 +362,8 @@ def raw_format_flow(f, focus, extended, truncate_urls):
|
|||||||
|
|
||||||
url = f["req_url"]
|
url = f["req_url"]
|
||||||
|
|
||||||
# TODO: Add a configuration setting that disables this behaviour?
|
if f["max_url_len"] and len(url) > f["max_url_len"]:
|
||||||
if truncate_urls and len(url) > truncate_urls:
|
url = url[:f["max_url_len"]] + "…"
|
||||||
url = url[:truncate_urls] + "..."
|
|
||||||
|
|
||||||
if f["req_http_version"] not in ("HTTP/1.0", "HTTP/1.1"):
|
if f["req_http_version"] not in ("HTTP/1.0", "HTTP/1.1"):
|
||||||
url += " " + f["req_http_version"]
|
url += " " + f["req_http_version"]
|
||||||
@ -389,7 +390,7 @@ def raw_format_flow(f, focus, extended, truncate_urls):
|
|||||||
if f["resp_is_replay"]:
|
if f["resp_is_replay"]:
|
||||||
resp.append(fcol(SYMBOL_REPLAY, "replay"))
|
resp.append(fcol(SYMBOL_REPLAY, "replay"))
|
||||||
resp.append(fcol(f["resp_code"], ccol))
|
resp.append(fcol(f["resp_code"], ccol))
|
||||||
if extended:
|
if f["extended"]:
|
||||||
resp.append(fcol(f["resp_reason"], ccol))
|
resp.append(fcol(f["resp_reason"], ccol))
|
||||||
if f["intercepted"] and f["resp_code"] and not f["acked"]:
|
if f["intercepted"] and f["resp_code"] and not f["acked"]:
|
||||||
rc = "intercept"
|
rc = "intercept"
|
||||||
@ -415,8 +416,12 @@ def raw_format_flow(f, focus, extended, truncate_urls):
|
|||||||
return urwid.Pile(pile)
|
return urwid.Pile(pile)
|
||||||
|
|
||||||
|
|
||||||
def format_flow(f, focus, extended=False, hostheader=False, truncate_urls=False):
|
def format_flow(f, focus, extended=False, hostheader=False, max_url_len=False):
|
||||||
d = dict(
|
d = dict(
|
||||||
|
focus=focus,
|
||||||
|
extended=extended,
|
||||||
|
max_url_len=max_url_len,
|
||||||
|
|
||||||
intercepted = f.intercepted,
|
intercepted = f.intercepted,
|
||||||
acked = f.reply.state == "committed",
|
acked = f.reply.state == "committed",
|
||||||
|
|
||||||
@ -454,10 +459,5 @@ def format_flow(f, focus, extended=False, hostheader=False, truncate_urls=False)
|
|||||||
d["resp_ctype"] = t.split(";")[0]
|
d["resp_ctype"] = t.split(";")[0]
|
||||||
else:
|
else:
|
||||||
d["resp_ctype"] = ""
|
d["resp_ctype"] = ""
|
||||||
return flowcache.get(
|
|
||||||
raw_format_flow,
|
return flowcache.get(raw_format_flow, tuple(sorted(d.items())))
|
||||||
tuple(sorted(d.items())),
|
|
||||||
focus,
|
|
||||||
extended,
|
|
||||||
truncate_urls,
|
|
||||||
)
|
|
||||||
|
@ -121,7 +121,7 @@ class ConnectionItem(urwid.WidgetWrap):
|
|||||||
self.flow,
|
self.flow,
|
||||||
self.f,
|
self.f,
|
||||||
hostheader=self.master.options.showhost,
|
hostheader=self.master.options.showhost,
|
||||||
truncate_urls=cols,
|
max_url_len=cols,
|
||||||
)
|
)
|
||||||
|
|
||||||
def selectable(self):
|
def selectable(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user