bugfix: make compatible with download api that response in bytes

This commit is contained in:
debugtalk
2018-05-14 17:14:44 +08:00
parent 6f6d0bdf5a
commit ca39577175
2 changed files with 12 additions and 9 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
__title__ = 'HttpRunner' __title__ = 'HttpRunner'
__description__ = 'One-stop solution for HTTP(S) testing.' __description__ = 'One-stop solution for HTTP(S) testing.'
__url__ = 'https://github.com/HttpRunner/HttpRunner' __url__ = 'https://github.com/HttpRunner/HttpRunner'
__version__ = '1.4.3' __version__ = '1.4.4'
__author__ = 'debugtalk' __author__ = 'debugtalk'
__author_email__ = 'mail@debugtalk.com' __author_email__ = 'mail@debugtalk.com'
__license__ = 'MIT' __license__ = 'MIT'
+3
View File
@@ -118,6 +118,7 @@ def stringify_body(meta_data, request_or_response):
elif isinstance(body, bytes): elif isinstance(body, bytes):
resp_content_type = headers.get("Content-Type", "") resp_content_type = headers.get("Content-Type", "")
try:
if "image" in resp_content_type: if "image" in resp_content_type:
meta_data["response_data_type"] = "image" meta_data["response_data_type"] = "image"
body = "data:{};base64,{}".format( body = "data:{};base64,{}".format(
@@ -126,6 +127,8 @@ def stringify_body(meta_data, request_or_response):
) )
else: else:
body = body.decode("utf-8") body = body.decode("utf-8")
except UnicodeDecodeError:
pass
elif not isinstance(body, (basestring, numeric_types, Iterable)): elif not isinstance(body, (basestring, numeric_types, Iterable)):
# class instance, e.g. MultipartEncoder() # class instance, e.g. MultipartEncoder()