mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-06 16:07:45 +08:00
bugfix: make compatible with download api that response in bytes
This commit is contained in:
@@ -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'
|
||||||
|
|||||||
+11
-8
@@ -118,14 +118,17 @@ 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", "")
|
||||||
if "image" in resp_content_type:
|
try:
|
||||||
meta_data["response_data_type"] = "image"
|
if "image" in resp_content_type:
|
||||||
body = "data:{};base64,{}".format(
|
meta_data["response_data_type"] = "image"
|
||||||
resp_content_type,
|
body = "data:{};base64,{}".format(
|
||||||
b64encode(body).decode('utf-8')
|
resp_content_type,
|
||||||
)
|
b64encode(body).decode('utf-8')
|
||||||
else:
|
)
|
||||||
body = body.decode("utf-8")
|
else:
|
||||||
|
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()
|
||||||
|
|||||||
Reference in New Issue
Block a user