Drop HTML line breaks on long headers

This commit is contained in:
Tom Christie 2024-06-14 10:29:28 +01:00
parent 9864c47018
commit bf9212d070
2 changed files with 1 additions and 12 deletions

View File

@ -176,7 +176,7 @@
<div class="response-info" aria-label="{% trans "response info" %}"> <div class="response-info" aria-label="{% trans "response info" %}">
<pre class="prettyprint"><span class="meta nocode"><b>HTTP {{ response.status_code }} {{ response.status_text }}</b>{% for key, val in response_headers|items %} <pre class="prettyprint"><span class="meta nocode"><b>HTTP {{ response.status_code }} {{ response.status_text }}</b>{% for key, val in response_headers|items %}
<b>{{ key }}:</b> <span class="lit">{{ val|break_long_headers|urlize }}</span>{% endfor %} <b>{{ key }}:</b> <span class="lit">{{ val|urlize }}</span>{% endfor %}
</span>{{ content|urlize }}</pre> </span>{{ content|urlize }}</pre>
</div> </div>

View File

@ -313,14 +313,3 @@ def smart_urlquote_wrapper(matched_url):
return smart_urlquote(matched_url) return smart_urlquote(matched_url)
except ValueError: except ValueError:
return None return None
@register.filter
def break_long_headers(header):
"""
Breaks headers longer than 160 characters (~page length)
when possible (are comma separated)
"""
if len(header) > 160 and ',' in header:
header = mark_safe('<br> ' + ', <br>'.join(header.split(',')))
return header