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
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
# Aliasing it for the sake of page size.
|
||||
from django.utils.html import strip_spaces_between_tags as short
|
||||
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 u'text/html' in response['Content-Type']:
|
||||
response.content = short(response.content)
|
||||
if 'text/html' in response.get('Content-Type', ''):
|
||||
response.content = strip_spaces_between_tags(response.content)
|
||||
return response
|
||||
|
||||
Reference in New Issue
Block a user