aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormadt1m <blackjuniper@protonmail.com>2018-06-30 11:16:59 +0200
committermadt1m <blackjuniper@protonmail.com>2018-06-30 11:16:59 +0200
commit54cae95a9026e38cc2ab26f3379de11daaa3c399 (patch)
treea10bf8eb858e1c306f7eb0fc987f60ebccf0f9da
parent189e2ce0d0bd39364c87ce6cb032e21e3c365264 (diff)
downloadmitmproxy-54cae95a9026e38cc2ab26f3379de11daaa3c399.tar.gz
mitmproxy-54cae95a9026e38cc2ab26f3379de11daaa3c399.tar.bz2
mitmproxy-54cae95a9026e38cc2ab26f3379de11daaa3c399.zip
new protobuf loads has almost the same result of FlowReader stream
-rw-r--r--mitmproxy/io/protobuf.py9
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")))