diff options
author | madt1m <blackjuniper@protonmail.com> | 2018-06-30 11:16:59 +0200 |
---|---|---|
committer | madt1m <blackjuniper@protonmail.com> | 2018-06-30 11:16:59 +0200 |
commit | 54cae95a9026e38cc2ab26f3379de11daaa3c399 (patch) | |
tree | a10bf8eb858e1c306f7eb0fc987f60ebccf0f9da /mitmproxy | |
parent | 189e2ce0d0bd39364c87ce6cb032e21e3c365264 (diff) | |
download | mitmproxy-54cae95a9026e38cc2ab26f3379de11daaa3c399.tar.gz mitmproxy-54cae95a9026e38cc2ab26f3379de11daaa3c399.tar.bz2 mitmproxy-54cae95a9026e38cc2ab26f3379de11daaa3c399.zip |
new protobuf loads has almost the same result of FlowReader stream
Diffstat (limited to 'mitmproxy')
-rw-r--r-- | mitmproxy/io/protobuf.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/mitmproxy/io/protobuf.py b/mitmproxy/io/protobuf.py index 54dc1437..3db9a013 100644 --- a/mitmproxy/io/protobuf.py +++ b/mitmproxy/io/protobuf.py @@ -16,7 +16,10 @@ def _move_attrs(s_obj, d_obj, attrs): setattr(d_obj, attr, getattr(s_obj, attr)) else: if hasattr(s_obj, attr) and getattr(s_obj, attr) is not None: - d_obj[attr] = getattr(s_obj, attr) + if not getattr(s_obj, attr): + d_obj[attr] = None + else: + d_obj[attr] = getattr(s_obj, attr) def _dump_http_response(res: HTTPResponse) -> http_pb2.HTTPResponse: @@ -105,6 +108,8 @@ def _load_http_request(o: http_pb2.HTTPRequest) -> HTTPRequest: d = {} _move_attrs(o, d, ['first_line_format', 'method', 'scheme', 'host', 'port', 'path', 'http_version', 'content', 'timestamp_start', 'timestamp_end', 'is_replay']) + if d['content'] is None: + d['content'] = b"" d["headers"] = [] for header in o.headers: d["headers"].append((bytes(header.name, "utf-8"), bytes(header.value, "utf-8"))) @@ -116,6 +121,8 @@ def _load_http_response(o: http_pb2.HTTPResponse) -> HTTPResponse: d = {} _move_attrs(o, d, ['http_version', 'status_code', 'reason', 'content', 'timestamp_start', 'timestamp_end', 'is_replay']) + if d['content'] is None: + d['content'] = b"" d["headers"] = [] for header in o.headers: d["headers"].append((bytes(header.name, "utf-8"), bytes(header.value, "utf-8"))) |