From 9af41b7f7262cd1dd59292d3290e725f7e16c7b9 Mon Sep 17 00:00:00 2001 From: r00t Date: Mon, 25 Jan 2021 16:27:33 +0100 Subject: [PATCH] fix conversion of old flows failing due to missing array keys --- mitmproxy/io/compat.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/mitmproxy/io/compat.py b/mitmproxy/io/compat.py index 2f098758f..9fe075d5f 100644 --- a/mitmproxy/io/compat.py +++ b/mitmproxy/io/compat.py @@ -174,19 +174,22 @@ def convert_6_7(data): def convert_7_8(data): data["version"] = 8 - data["request"]["trailers"] = None - if data["response"] is not None: + if "request" in data and data["request"] is not None: + data["request"]["trailers"] = None + if "response" in data and data["response"] is not None: data["response"]["trailers"] = None return data def convert_8_9(data): data["version"] = 9 - data["request"].pop("first_line_format") - data["request"]["authority"] = b"" - is_request_replay = data["request"].pop("is_replay", False) + is_request_replay = False + if "request" in data: + data["request"].pop("first_line_format") + data["request"]["authority"] = b"" + is_request_replay = data["request"].pop("is_replay", False) is_response_replay = False - if data["response"] is not None: + if "response" in data and data["response"] is not None: is_response_replay = data["response"].pop("is_replay", False) if is_request_replay: # pragma: no cover data["is_replay"] = "request"