Skip to content

Commit

Permalink
Tweak timing display
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
cortesi committed Aug 22, 2013
1 parent 09f6512 commit a2643b5
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
10 changes: 4 additions & 6 deletions libmproxy/console/common.py
Expand Up @@ -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"))
Expand Down Expand Up @@ -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"]
Expand Down
1 change: 0 additions & 1 deletion libmproxy/console/palettes.py
Expand Up @@ -35,7 +35,6 @@

('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'),
Expand Down
2 changes: 1 addition & 1 deletion libmproxy/flow.py
Expand Up @@ -618,7 +618,7 @@ def __init__(self, request, httpversion, code, msg, headers, content, cert, time
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):
Expand Down
7 changes: 5 additions & 2 deletions libmproxy/proxy.py
Expand Up @@ -88,11 +88,13 @@ def run(self):
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:
Expand Down Expand Up @@ -224,6 +226,7 @@ def handle_request(self, cc):
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,
Expand All @@ -242,7 +245,7 @@ def handle_request(self, cc):

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
Expand Down

0 comments on commit a2643b5

Please sign in to comment.