aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBkPHcgQL3V <BkPHcgQL3V@gmx.com>2018-12-17 05:28:23 +0000
committerMaximilian Hils <git@maximilianhils.com>2018-12-17 18:25:14 +0100
commit889987aa0a7f4852758ed09f70fe5d30f733a6d3 (patch)
treef00ed14cb9ed7cc989e8cc363cda8118acd4c122
parente2bcca47b1ad8040451cbd95039acf200e9b0e84 (diff)
downloadmitmproxy-889987aa0a7f4852758ed09f70fe5d30f733a6d3.tar.gz
mitmproxy-889987aa0a7f4852758ed09f70fe5d30f733a6d3.tar.bz2
mitmproxy-889987aa0a7f4852758ed09f70fe5d30f733a6d3.zip
Fix Flow being part of raw_format_flow cache key
raw_format_flow is annotated with the @lru_cache decorator, which creates a cache of the function's return value based on its parameters. Thus, assuming that the first argument (f) contains all the information needed to compute the urwid control for the flow, this effectively caches results. To make most use of this, remove the second parameter representing the real Flow object to improve @lru_cache's efficiency.
-rw-r--r--mitmproxy/tools/console/common.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/mitmproxy/tools/console/common.py b/mitmproxy/tools/console/common.py
index 72282015..5d7ee09d 100644
--- a/mitmproxy/tools/console/common.py
+++ b/mitmproxy/tools/console/common.py
@@ -106,7 +106,7 @@ else:
@lru_cache(maxsize=800)
-def raw_format_flow(f, flow):
+def raw_format_flow(f):
f = dict(f)
pile = []
req = []
@@ -126,8 +126,7 @@ def raw_format_flow(f, flow):
if f["req_is_replay"]:
req.append(fcol(SYMBOL_REPLAY, "replay"))
- pushed = ' PUSH_PROMISE' if 'h2-pushed-stream' in flow.metadata else ''
- req.append(fcol(f["req_method"] + pushed, "method"))
+ req.append(fcol(f["req_method"], "method"))
preamble = sum(i[1] for i in req) + len(req) - 1
@@ -198,6 +197,7 @@ def format_flow(f, focus, extended=False, hostheader=False, max_url_len=False):
acked = False
if f.reply and f.reply.state == "committed":
acked = True
+ pushed = ' PUSH_PROMISE' if 'h2-pushed-stream' in f.metadata else ''
d = dict(
focus=focus,
extended=extended,
@@ -206,7 +206,7 @@ def format_flow(f, focus, extended=False, hostheader=False, max_url_len=False):
acked=acked,
req_timestamp=f.request.timestamp_start,
req_is_replay=f.request.is_replay,
- req_method=f.request.method,
+ req_method=f.request.method + pushed,
req_url=f.request.pretty_url if hostheader else f.request.url,
req_http_version=f.request.http_version,
err_msg=f.error.msg if f.error else None,
@@ -238,4 +238,4 @@ def format_flow(f, focus, extended=False, hostheader=False, max_url_len=False):
else:
d["resp_ctype"] = ""
- return raw_format_flow(tuple(sorted(d.items())), f)
+ return raw_format_flow(tuple(sorted(d.items())))