From a2643b52f909719d4e0fe97e17d3d30f43669341 Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Fri, 23 Aug 2013 10:01:19 +1200 Subject: [PATCH] Tweak timing display - Remove elapsed time. Space is at a premium here, and this is somewhat redundant with the rate figure. We should display complete timing information somewhere in the detailed flow view. - Tone down the colour. Reserve highlights for stuff that should really pop out to the user. - Make rate calculation more acurate. Include header sizes. Use response start and end time, rather than request end and response end. This means that we show actual transfer rates, not including DNS requests and so forth. --- libmproxy/console/common.py | 10 ++++------ libmproxy/console/palettes.py | 1 - libmproxy/flow.py | 2 +- libmproxy/proxy.py | 7 +++++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/libmproxy/console/common.py b/libmproxy/console/common.py index 748302377..006303a76 100644 --- a/libmproxy/console/common.py +++ b/libmproxy/console/common.py @@ -144,9 +144,7 @@ def raw_format_flow(f, focus, extended, padding): if f["resp_ctype"]: resp.append(fcol(f["resp_ctype"], rc)) resp.append(fcol(f["resp_clen"], rc)) - - resp.append(fcol(f["resp_et"], "time")) - resp.append(fcol(f["resp_rate"], "highlight")) + resp.append(fcol(f["resp_rate"], rc)) elif f["err_msg"]: resp.append(fcol(SYMBOL_RETURN, "error")) @@ -190,15 +188,15 @@ def format_flow(f, focus, extended=False, hostheader=False, padding=2): else: contentdesc = "[no content]" - delta = f.response.timestamp_end - f.request.timestamp_start - rate = utils.pretty_size(len(f.response.content) / delta) + delta = f.response.timestamp_end - f.response.timestamp_start + size = len(f.response.content) + f.response.get_header_size() + rate = utils.pretty_size(size / delta) d.update(dict( resp_code = f.response.code, resp_is_replay = f.response.is_replay(), resp_acked = f.response.reply.acked, resp_clen = contentdesc, - resp_et = "{0:2.0f}ms".format(delta * 1000), resp_rate = "{0}/s".format(rate), )) t = f.response.headers["content-type"] diff --git a/libmproxy/console/palettes.py b/libmproxy/console/palettes.py index df84a1e4f..650cf2618 100644 --- a/libmproxy/console/palettes.py +++ b/libmproxy/console/palettes.py @@ -35,7 +35,6 @@ palettes = { ('header', 'dark cyan', 'default'), ('highlight', 'white,bold', 'default'), - ('time', 'light red', 'default'), ('intercept', 'brown', 'default', None, '#f60', 'default'), ('replay', 'light green', 'default', None, '#0f0', 'default'), ('ack', 'light red', 'default'), diff --git a/libmproxy/flow.py b/libmproxy/flow.py index 84836d111..240428126 100644 --- a/libmproxy/flow.py +++ b/libmproxy/flow.py @@ -618,7 +618,7 @@ class Response(HTTPMsg): self.headers, self.content = headers, content self.cert = cert self.timestamp_start = timestamp_start or utils.timestamp() - self.timestamp_end = max(timestamp_end or utils.timestamp(), timestamp_start) + self.timestamp_end = timestamp_end or utils.timestamp() self.replay = False def _refresh_cookie(self, c, delta): diff --git a/libmproxy/proxy.py b/libmproxy/proxy.py index b0c154631..75a541920 100644 --- a/libmproxy/proxy.py +++ b/libmproxy/proxy.py @@ -88,11 +88,13 @@ class RequestReplayThread(threading.Thread): server = ServerConnection(self.config, r.scheme, r.host, r.port, r.host) server.connect() server.send(r) + tsstart = utils.timestamp() httpversion, code, msg, headers, content = http.read_response( server.rfile, r.method, self.config.body_size_limit ) response = flow.Response( - self.flow.request, httpversion, code, msg, headers, content, server.cert + self.flow.request, httpversion, code, msg, headers, content, server.cert, + server.rfile.first_byte_timestamp ) self.channel.ask(response) except (ProxyError, http.HttpError, tcp.NetLibError), v: @@ -224,6 +226,7 @@ class ProxyHandler(tcp.BaseHandler): request.ssl_setup_timestamp = sc.ssl_setup_timestamp sc.rfile.reset_timestamps() try: + tsstart = utils.timestamp() httpversion, code, msg, headers, content = http.read_response( sc.rfile, request.method, @@ -242,7 +245,7 @@ class ProxyHandler(tcp.BaseHandler): response = flow.Response( request, httpversion, code, msg, headers, content, sc.cert, - sc.rfile.first_byte_timestamp, utils.timestamp() + sc.rfile.first_byte_timestamp ) response_reply = self.channel.ask(response) # Not replying to the server invalidates the server