#10190: Charset should be customizable with HttpResponse
------------------------------------+---------------------------------------
Reporter: Wonlay | Owner: nobody
Status: new | Milestone:
Component: HTTP handling | Version: SVN
Resolution: | Keywords: HttpResponse, charset,
runtime
Stage: Unreviewed | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 1 |
------------------------------------+---------------------------------------
Changes (by mtredinnick):
* needs_better_patch: => 1
* needs_tests: => 0
* needs_docs: => 0
Comment:
This patch should probably be just a one-liner: just setting
`self._charset`. Don't mess around with the `mimetype` stuff, since that's
not related. However, there's something more that should be worked out
here to avoid all problems.
If the value of `self._charset` is always going to be valid in the HTTP
content-type header, we should just extract it from the `content_type`
parameter. That would only be valid if all Python codec values are also
valid HTTP header values.
If that isn't possible, then `self._charset` shouldn't be used to
construct the content-type header, as it will use an invalid value. The
current "default" is only for really old code (and/or people using
defaults likes utf-8). For anything non-standard, `content_type` should be
being used with a proper character set definition.
So, improvements needed here are:
1. Remove the changes to `mimetype` setting. Make the smallest change
possible and that isn't needed.
2. Find out whether Python codec names are all valid as HTTP charset
names. If so, parse the `content_type` to see if a special charset
encoding is needed (no need for an extra `__init__` parameter).
3. If the previous item is not applicable, don't use `_charset` in the
`content_type` setting, since it could lead to invalid value (and we'll
need a documentation update to clarify the requirements there).
--
Ticket URL: <http://code.djangoproject.com/ticket/10190#comment:1>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---