fix: compatibility when request body is None

This commit is contained in:
debugtalk
2020-05-29 11:34:17 +08:00
parent 45a5f1c37c
commit 1134bb523b

View File

@@ -45,7 +45,14 @@ def get_req_resp_record(resp_obj: Response) -> ReqRespData:
request_body = resp_obj.request.body
try:
request_body = json.loads(request_body)
except (json.JSONDecodeError, UnicodeDecodeError):
except json.JSONDecodeError:
# str: Unexpected UTF-8 BOM (decode using utf-8-sig)
pass
except UnicodeDecodeError:
# bytes/bytearray: request body in protobuf
pass
except TypeError:
# neither str nor bytes/bytearray, e.g. None
pass
if request_body: