I don't know if anyone will find this useful, but I thought I'd throw
it out there.

I wrote a little Middleware class to strip trailing and leading
whitespace from a response:

import re
class StripWhitespaceMiddleware:
    """
    Strips leading and trailing whitespace from response content.
    """

    def __init__(self):
        self.whitespace = re.compile('\s*\n+\s*')


    def process_response(self, request, response):
        new_content = self.whitespace.sub('\n', response.content)
        response.content = new_content
        return response


This is /nothing special/, I know.  It might not even be worth it,
performance-wise.  Just thought I'd throw it out there.  Just my noob
way of trying to help out...

If you use it, just make sure it comes after GZipMiddleware in the
MIDDLEWARE_CLASSES tuple.

doug.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers
-~----------~----~----~----~------~----~------~--~---

Reply via email to