diff options
author | Shadab Zafar <dufferzafar0@gmail.com> | 2016-03-01 20:20:18 +0530 |
---|---|---|
committer | Shadab Zafar <dufferzafar0@gmail.com> | 2016-03-01 20:20:18 +0530 |
commit | 27faea2355218c90e5baa962b15653c17faf2f85 (patch) | |
tree | 3817d947820351009e36ecbcc7f63a269cc79182 | |
parent | 3de89ab16c320350f20c828763b11a47cf2a2807 (diff) | |
download | mitmproxy-27faea2355218c90e5baa962b15653c17faf2f85.tar.gz mitmproxy-27faea2355218c90e5baa962b15653c17faf2f85.tar.bz2 mitmproxy-27faea2355218c90e5baa962b15653c17faf2f85.zip |
Fixup HAR Extractor
-rw-r--r-- | examples/har_extractor.py | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/examples/har_extractor.py b/examples/har_extractor.py index e7718fe8..90c7bbf0 100644 --- a/examples/har_extractor.py +++ b/examples/har_extractor.py @@ -1,5 +1,4 @@ """ - This inline script utilizes harparser.HAR from https://github.com/JustusW/harparser to generate a HAR log object. """ @@ -122,26 +121,38 @@ def response(context, flow): if item > -1: full_time += item - started_date_time = datetime.fromtimestamp( - flow.request.timestamp_start, - tz=utc).isoformat() + started_date_time = datetime.utcfromtimestamp( + flow.request.timestamp_start).isoformat() + + request_query_string = "" + if flow.request.query: + request_query_string = [{"name": k, "value": v} + for k, v in flow.request.query] - request_query_string = [{"name": k, "value": v} - for k, v in flow.request.query] request_http_version = flow.request.http_version # Cookies are shaped as tuples by MITMProxy. request_cookies = [{"name": k.strip(), "value": v[0]} for k, v in flow.request.cookies.items()] - request_headers = [{"name": k, "value": v} for k, v in flow.request.headers] + + request_headers = "" + if flow.request.headers: + request_headers = [{"name": k, "value": v} + for k, v in flow.request.headers.fields] + request_headers_size = len(str(flow.request.headers)) request_body_size = len(flow.request.content) response_http_version = flow.response.http_version + # Cookies are shaped as tuples by MITMProxy. response_cookies = [{"name": k.strip(), "value": v[0]} for k, v in flow.response.cookies.items()] - response_headers = [{"name": k, "value": v} - for k, v in flow.response.headers] + + response_headers = "" + if flow.response.headers: + response_headers = [{"name": k, "value": v} + for k, v in flow.response.headers.fields] + response_headers_size = len(str(flow.response.headers)) response_body_size = len(flow.response.content) response_body_decoded_size = len(flow.response.get_decoded_content()) |