fix #191: request data dumps

This commit is contained in:
debugtalk
2018-04-20 22:00:56 +08:00
parent e5191fd740
commit 0a3f5cc146
2 changed files with 34 additions and 1 deletions

View File

@@ -137,7 +137,7 @@ def setup_hook_prepare_kwargs(method, url, kwargs):
content_type = kwargs.get("headers", {}).get("content-type")
if content_type and "data" in kwargs:
# if request content-type is application/json, request data should be dumped
if content_type.startswith("application/json"):
if content_type.startswith("application/json") and isinstance(kwargs["data"], (dict, list)):
kwargs["data"] = json.dumps(kwargs["data"])
if isinstance(kwargs["data"], str):