mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-05 23:51:25 +08:00
fix html report display response content
This commit is contained in:
@@ -138,10 +138,16 @@ class HttpSession(requests.Session):
|
|||||||
self.meta_data["response"]["headers"] = dict(response.headers)
|
self.meta_data["response"]["headers"] = dict(response.headers)
|
||||||
self.meta_data["response"]["cookies"] = response.cookies or {}
|
self.meta_data["response"]["cookies"] = response.cookies or {}
|
||||||
self.meta_data["response"]["encoding"] = response.encoding
|
self.meta_data["response"]["encoding"] = response.encoding
|
||||||
self.meta_data["response"]["content_type"] = response.headers.get("Content-Type", "")
|
|
||||||
|
|
||||||
|
content_type = response.headers.get("Content-Type", "")
|
||||||
|
self.meta_data["response"]["content_type"] = content_type
|
||||||
|
|
||||||
|
if "image" in content_type:
|
||||||
|
# response is image type, record bytes content only
|
||||||
|
self.meta_data["response"]["content"] = response.content
|
||||||
|
else:
|
||||||
try:
|
try:
|
||||||
# try to only record json data
|
# try to record json data
|
||||||
self.meta_data["response"]["json"] = response.json()
|
self.meta_data["response"]["json"] = response.json()
|
||||||
except ValueError:
|
except ValueError:
|
||||||
# only record at most 1000 text charactors
|
# only record at most 1000 text charactors
|
||||||
|
|||||||
@@ -272,7 +272,7 @@
|
|||||||
<div style="overflow: auto">
|
<div style="overflow: auto">
|
||||||
<table>
|
<table>
|
||||||
{% for key, value in record.meta_data.response.items() %}
|
{% for key, value in record.meta_data.response.items() %}
|
||||||
{% if key in ["text", "json", "elapsed_ms", "response_time_ms", "content_size", "content_type"] %}
|
{% if key in ["elapsed_ms", "response_time_ms", "content_size", "content_type"] %}
|
||||||
{% continue %}
|
{% continue %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<tr>
|
<tr>
|
||||||
@@ -288,8 +288,10 @@
|
|||||||
{% if "image" in record.meta_data.response.content_type %}
|
{% if "image" in record.meta_data.response.content_type %}
|
||||||
<img src="{{ record.meta_data.response.content }}" />
|
<img src="{{ record.meta_data.response.content }}" />
|
||||||
{% else %}
|
{% else %}
|
||||||
<pre>{{ record.meta_data.response.text | e }}</pre>
|
{{ value }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% elif key == "text" %}
|
||||||
|
<pre>{{ record.meta_data.response.text | e }}</pre>
|
||||||
{% else %}
|
{% else %}
|
||||||
{{ value }}
|
{{ value }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|||||||
Reference in New Issue
Block a user