Commit 416cca85 by Timothée Peignier

improve middleware

parent 3e4fd4f1
...@@ -4,7 +4,7 @@ from django.utils.html import strip_spaces_between_tags as minify_html ...@@ -4,7 +4,7 @@ from django.utils.html import strip_spaces_between_tags as minify_html
class MinifyHTMLMiddleware(object): class MinifyHTMLMiddleware(object):
def process_response(self, request, response): def process_response(self, request, response):
if 'text/html' in response['Content-Type']: if response.has_header('Content-Type') and 'text/html' in response['Content-Type']:
try: try:
response.content = minify_html(response.content.strip()) response.content = minify_html(response.content.strip())
except DjangoUnicodeDecodeError: except DjangoUnicodeDecodeError:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment