Doug Van Horn wrote:
> I wrote a little Middleware class to strip trailing and leading
> whitespace from a response:

I may be misunderstanding something, but doesn't your middleware
actually leave whitespace at the beginning and end of the response?

If response.content = '\n\n\nHello.\n\n' it is converted to
'\nHello.\n'.

Couldn't you change your middleware to something simpler, like this, to
actually strip off all of the leading and trailing whitespace?


class StripWhitespaceMiddleware:
    """Strips leading and trailing whitespace from response content."""
    def process_response(self, request, response):
        response.content = response.content.strip()
        return response


Just a thought.  As I said, I may be misunderstanding something.


Will.


--~--~---------~--~----~------------~-------~--~----~
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