Nicer coloring for HTTP response codes.

20x: green
30x: blue
40x: orange
50x: light red
other (non-standard or uncommon): dark red
This commit is contained in:
Aldo Cortesi 2012-04-02 14:08:30 +12:00
parent c02fdb2463
commit bb03255da0
2 changed files with 17 additions and 10 deletions

View File

@ -137,17 +137,17 @@ def raw_format_flow(f, focus, extended, padding):
) )
if f["resp_code"]: if f["resp_code"]:
if f["resp_code"] in [200, 304]: codes = {
resp.append(fcol(SYMBOL_RETURN, "goodcode")) 2: "code_200",
else: 3: "code_300",
resp.append(fcol(SYMBOL_RETURN, "error")) 4: "code_400",
5: "code_500",
}
ccol = codes.get(f["resp_code"]/100, "code_other")
resp.append(fcol(SYMBOL_RETURN, ccol))
if f["resp_is_replay"]: if f["resp_is_replay"]:
resp.append(fcol(SYMBOL_REPLAY, "replay")) resp.append(fcol(SYMBOL_REPLAY, "replay"))
if f["resp_code"] in [200, 304]: resp.append(fcol(f["resp_code"], ccol))
resp.append(fcol(f["resp_code"], "goodcode"))
else:
resp.append(fcol(f["resp_code"], "error"))
if f["intercepting"] and f["resp_code"] and not f["resp_acked"]: if f["intercepting"] and f["resp_code"] and not f["resp_acked"]:
rc = "intercept" rc = "intercept"
else: else:

View File

@ -33,8 +33,15 @@ dark = [
# List and Connections # List and Connections
('method', 'dark cyan', 'default'), ('method', 'dark cyan', 'default'),
('focus', 'yellow', 'default'), ('focus', 'yellow', 'default'),
('goodcode', 'light green', 'default'),
('code_200', 'light green', 'default'),
('code_300', 'light blue', 'default'),
('code_400', 'light red', 'default', None, "#f60", "default"),
('code_500', 'light red', 'default'),
('code_other', 'dark red', 'default'),
('error', 'light red', 'default'), ('error', 'light red', 'default'),
('header', 'dark cyan', 'default'), ('header', 'dark cyan', 'default'),
('highlight', 'white,bold', 'default'), ('highlight', 'white,bold', 'default'),
('intercept', 'brown', 'default', None, "#f60", "default"), ('intercept', 'brown', 'default', None, "#f60", "default"),