minor fixes

This commit is contained in:
Maximilian Hils 2020-12-05 22:20:09 +01:00
parent 2d35c7bc4f
commit a115fff410
2 changed files with 13 additions and 4 deletions

View File

@ -23,7 +23,7 @@ from mitmproxy import ctx
from mitmproxy import io from mitmproxy import io
from mitmproxy import http from mitmproxy import http
from mitmproxy import tcp from mitmproxy import tcp
from mitmproxy.utils import human from mitmproxy.utils import compat, human
# The underlying sorted list implementation expects the sort key to be stable # The underlying sorted list implementation expects the sort key to be stable
@ -460,8 +460,12 @@ class View(collections.abc.Sequence):
req = http.HTTPRequest.make(method.upper(), url) req = http.HTTPRequest.make(method.upper(), url)
except ValueError as e: except ValueError as e:
raise exceptions.CommandError("Invalid URL: %s" % e) raise exceptions.CommandError("Invalid URL: %s" % e)
c = connections.ClientConnection.make_dummy(("", 0)) if compat.new_proxy_core: # pragma: no cover
s = connections.ServerConnection.make_dummy((req.host, req.port)) c = compat.Client(("", 0), ("", 0), req.timestamp_start - 0.0001)
s = compat.Server((req.host, req.port))
else: # pragma: no cover
c = connections.ClientConnection.make_dummy(("", 0))
s = connections.ServerConnection.make_dummy((req.host, req.port))
f = http.HTTPFlow(c, s) f = http.HTTPFlow(c, s)
f.request = req f.request = req
f.request.headers["Host"] = req.host f.request.headers["Host"] = req.host

View File

@ -12,7 +12,12 @@ def maybe_timestamp(base, attr):
if base is not None and getattr(base, attr): if base is not None and getattr(base, attr):
return human.format_timestamp_with_milli(getattr(base, attr)) return human.format_timestamp_with_milli(getattr(base, attr))
else: else:
return "active" # in mitmdump we serialize before a connection is closed.
# loading those flows at a later point shouldn't display "active".
# We also use a ndash (and not a regular dash) so that it is sorted
# after other timestamps. We may need to revisit that in the future if it turns out
# to render ugly in consoles.
return ""
def flowdetails(state, flow: mitmproxy.flow.Flow): def flowdetails(state, flow: mitmproxy.flow.Flow):