From 1134bb523b26e13d741b382c3523a6767e6c9c80 Mon Sep 17 00:00:00 2001 From: debugtalk Date: Fri, 29 May 2020 11:34:17 +0800 Subject: [PATCH] fix: compatibility when request body is None --- httprunner/client.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/httprunner/client.py b/httprunner/client.py index 54f168e1..e1ade62a 100644 --- a/httprunner/client.py +++ b/httprunner/client.py @@ -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: