Skip to content
This repository has been archived by the owner on Jun 5, 2020. It is now read-only.

Commit

Permalink
bugfix: make compatible with invalid response application/json content
Browse files Browse the repository at this point in the history
  • Loading branch information
httprunner committed Feb 3, 2019
1 parent d1e3ede commit 64f8da2
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions har2case/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,13 +243,16 @@ def _make_validate(self, teststep_dict, entry_json):
encoding = resp_content_dict.get("encoding")
if encoding and encoding == "base64":
content = base64.b64decode(text).decode('utf-8')
try:
resp_content_json = json.loads(content)
except JSONDecodeError:
logging.warning("response content can not be loaded as json.")
return
else:
resp_content_json = json.loads(text)
content = text

try:
resp_content_json = json.loads(content)
except JSONDecodeError:
logging.warning(
"response content can not be loaded as json: {}".format(content)
)
return

if not isinstance(resp_content_json, dict):
return
Expand Down

0 comments on commit 64f8da2

Please sign in to comment.