mirror of
https://github.com/httprunner/httprunner.git
synced 2026-08-28 19:47:14 +08:00
feat: add keyword 'body' to reference response body
change: unify response field(content/json/text) to 'body' in html report
This commit is contained in:
@@ -2,10 +2,15 @@
|
|||||||
|
|
||||||
## 2.4.4 (2019-12-17)
|
## 2.4.4 (2019-12-17)
|
||||||
|
|
||||||
|
**Added**
|
||||||
|
|
||||||
|
- feat: add keyword `body` to reference response body
|
||||||
|
|
||||||
**Changed**
|
**Changed**
|
||||||
|
|
||||||
- refactor: dumps request/response headers, display indented json in html report
|
- refactor: dumps request/response headers, display indented json in html report
|
||||||
- refactor: dumps request/response body if it is in json format, display indented json in html report
|
- refactor: dumps request/response body if it is in json format, display indented json in html report
|
||||||
|
- change: unify response field(content/json/text) to `body` in html report
|
||||||
|
|
||||||
## 2.4.3 (2019-12-16)
|
## 2.4.3 (2019-12-16)
|
||||||
|
|
||||||
|
|||||||
@@ -111,18 +111,18 @@ class HttpSession(requests.Session):
|
|||||||
|
|
||||||
if "image" in content_type:
|
if "image" in content_type:
|
||||||
# response is image type, record bytes content only
|
# response is image type, record bytes content only
|
||||||
req_resp_dict["response"]["content"] = resp_obj.content
|
req_resp_dict["response"]["body"] = resp_obj.content
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
# try to record json data
|
# try to record json data
|
||||||
if isinstance(resp_obj, response.ResponseObject):
|
if isinstance(resp_obj, response.ResponseObject):
|
||||||
req_resp_dict["response"]["json"] = resp_obj.json
|
req_resp_dict["response"]["body"] = resp_obj.json
|
||||||
else:
|
else:
|
||||||
req_resp_dict["response"]["json"] = resp_obj.json()
|
req_resp_dict["response"]["body"] = resp_obj.json()
|
||||||
except ValueError:
|
except ValueError:
|
||||||
# only record at most 512 text charactors
|
# only record at most 512 text charactors
|
||||||
resp_text = resp_obj.text
|
resp_text = resp_obj.text
|
||||||
req_resp_dict["response"]["text"] = omit_long_data(resp_text)
|
req_resp_dict["response"]["body"] = omit_long_data(resp_text)
|
||||||
|
|
||||||
# log response details in debug mode
|
# log response details in debug mode
|
||||||
log_print(req_resp_dict, "response")
|
log_print(req_resp_dict, "response")
|
||||||
|
|||||||
@@ -217,7 +217,7 @@ def __stringify_response(response_data):
|
|||||||
if not encoding or encoding == "None":
|
if not encoding or encoding == "None":
|
||||||
encoding = "utf-8"
|
encoding = "utf-8"
|
||||||
|
|
||||||
if key == "content" and "image" in response_data["content_type"]:
|
if key == "body" and "image" in response_data["content_type"]:
|
||||||
# display image
|
# display image
|
||||||
value = "data:{};base64,{}".format(
|
value = "data:{};base64,{}".format(
|
||||||
response_data["content_type"],
|
response_data["content_type"],
|
||||||
|
|||||||
@@ -175,7 +175,7 @@ class ResponseObject(object):
|
|||||||
raise exceptions.ExtractFailure(err_msg)
|
raise exceptions.ExtractFailure(err_msg)
|
||||||
|
|
||||||
# response body
|
# response body
|
||||||
elif top_query in ["content", "text", "json"]:
|
elif top_query in ["body", "content", "text", "json"]:
|
||||||
try:
|
try:
|
||||||
body = self.json
|
body = self.json
|
||||||
except exceptions.JSONDecodeError:
|
except exceptions.JSONDecodeError:
|
||||||
|
|||||||
@@ -250,14 +250,14 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th>{{key}}</th>
|
<th>{{key}}</th>
|
||||||
<td>
|
<td>
|
||||||
{% if key == "content" %}
|
{% if key == "headers" %}
|
||||||
|
<pre>{{ value | e }}</pre>
|
||||||
|
{% elif key == "body" %}
|
||||||
{% if "image" in req_resp.response.content_type %}
|
{% if "image" in req_resp.response.content_type %}
|
||||||
<img src="{{ req_resp.response.content }}" />
|
<img src="{{ req_resp.response.content }}" />
|
||||||
{% else %}
|
{% else %}
|
||||||
{{ value }}
|
|
||||||
{% endif %}
|
|
||||||
{% elif key in ["headers", "text", "json"] %}
|
|
||||||
<pre>{{ value | e }}</pre>
|
<pre>{{ value | e }}</pre>
|
||||||
|
{% endif %}
|
||||||
{% else %}
|
{% else %}
|
||||||
{{ value }}
|
{{ value }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|||||||
Reference in New Issue
Block a user