durusmail: quixote-users: Re: Patch[1] for http_response.py for quixote-2.1
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
Re: Patch[1] for http_response.py for quixote-2.1
Hamish Lawson
2005-08-29
> Neil Schemenauer wrote:
> >
> > > Changing DEFAULT_CHARSET has no effect on what is the default for
> > > the HTTP protocol.
> >
> >
> > That doesn't appear to be quite what http_response.py says. If a
> > 'charset' parameter isn't provided to HTTPResponse's __init__ then
> > Quixote will use DEFAULT_CHARSET for the response, unless this is
> > overridden by a subsequent call to set_content_type.
>
> What does that all have to do with the default for the HTTP *protocol*?
> The default is iso-8859-1 and nothing Quixote does changes that.

Are you maybe reading too much into what is meant by the default
charset? The HTTP 1.1 standard specifies that "when no explicit
'charset' parameter is provided by the sender, media subtypes of the
'text' type are defined to have a default charset value of
'ISO-8859-1' when received via HTTP". [1] This speaks only to what a
receiver should understand; it says nothing about what character
encoding a sender is recommended to employ (if anything, UTF-8 would
be the W3C's recommendation [2]). Quixote could have adopted as its
own default any encoding it liked as long as this was declared in its
responses (although, as the W3C points out, "the more widely a
character encoding is used, the better the chance that a browser will
understand it"[3]). But I'm not even questioning Quixote's adoption of
ISO-8859-1 as its default. My point is simply this: regardless of any
defaults or recommendations, if Quixote provides me with the means to
specify a different character encoding, it should not reverse this
behind my back.

> Here's the counter example:
>
>         get_response().get_content_type('image/png')
>
> In that case, I don't want Quixote to use the existing charset.

In that case wouldn't you simply specify which charset you did want to
be used ("explicit is better than implicit" and all that [4])? I think
that is far preferable to Quixote's quietly changing it from what it
was before. (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.)

[1] http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.7.1
[2] http://www.w3.org/International/O-charset-lang.html
[3] http://www.w3.org/International/O-HTTP-charset
[4] http://www.python.org/peps/pep-0020.html


Hamish
reply