Files
mayan-edms/mayan/apps/common/middleware/strip_spaces_widdleware.py
Roberto Rosario d2ae771d6a Make sure the reponse has a Content-Type
Before trying to make sure it is an HTML response
or else it can causes errors in DELETE API responses
2014-07-24 12:31:07 -04:00

13 lines
390 B
Python

from django.utils.html import strip_spaces_between_tags
class SpacelessMiddleware(object):
"""
Remove spaces between tags in HTML responses to save on bandwidth
"""
def process_response(self, request, response):
if 'text/html' in response.get('Content-Type', ''):
response.content = strip_spaces_between_tags(response.content)
return response