Changes between Version 2 and Version 3 of StripWhitespaceMiddleware
- Timestamp:
- Dec 17, 2010, 5:11:53 PM (14 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
StripWhitespaceMiddleware
v2 v3 9 9 10 10 import re 11 11 12 class StripWhitespaceMiddleware: 12 13 """ 13 14 Strips leading and trailing whitespace from response content. 14 15 """ 16 15 17 def __init__(self): 16 18 self.whitespace = re.compile('\s*\n') 17 19 18 20 def process_response(self, request, response): 19 print dir(response) 20 print response.headers 21 if("text" in response['Content-Type'] ): 21 if "text" in response['Content-Type']: 22 22 new_content = self.whitespace.sub('\n', response.content) 23 23 response.content = new_content