durusmail: quixote-users: behavior of set_content_type()
Patch[1] for http_response.py for quixote-2.1
2005-08-21
2005-08-21
2005-08-29
2005-08-29
Re: Patch[1] for http_response.py for quixote-2.1
2005-08-29
2005-08-29
2005-09-01
behavior of set_content_type()
Re: behavior of set_content_type()
2005-08-30
2005-08-30
2005-08-30
behavior of set_content_type()
Neil Schemenauer
2005-08-30
On Mon, Aug 29, 2005 at 07:50:51PM +0100, Hamish Lawson wrote:
> And with regard to your particular example, the extract from the
> HTTP standard that I quoted above suggests that the charset
> parameter has no relevance for a binary type like image/png
> anyway.

Perhaps this will make everyone happy:

    def set_content_type(self, content_type, charset=None):
        """(content_type : string, charset : string = None)

        Set the content type of the response to the MIME type specified by
        'content_type'.  If 'charset' is not provided and the content_type is
        text/* then the charset attribute remains unchanged, otherwise the
        charset attribute is set to None and the charset parameter will not
        be included as part of the Content-Type header.
        """
        content_type = content_type.lower()
        if charset is not None or not content_type.startswith('text/'):
            self.charset = charset
        self.content_type = content_type

What do you think?

  Neil
reply