Changes between Version 7 and Version 8 of StripWhitespaceMiddleware
- Timestamp:
- May 6, 2012, 9:39:03 AM (13 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
StripWhitespaceMiddleware
v7 v8 25 25 26 26 def __init__(self): 27 self.whitespace = re.compile('^\s+', re.MULTILINE) 27 self.whitespace = re.compile('^\s*\n', re.MULTILINE) 28 self.whitespace_lead = re.compile('^\s+', re.MULTILINE) 28 29 self.whitespace_trail = re.compile('\s+$', re.MULTILINE) 29 30 … … 31 32 def process_response(self, request, response): 32 33 if "text" in response['Content-Type']: 33 new_content = self.whitespace.sub('', response.content) 34 # Uncomment the next line to remove empty lines 35 # new_content = self.whitespace.sub('', new_content) 36 new_content = self.whitespace_lead.sub('', response.content) 34 37 new_content = self.whitespace_trail.sub('\n', new_content) 35 38 response.content = new_content … … 38 41 return response 39 42 40 41 43 }}}