summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2010-09-11 01:41:53 +0000
committerMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2010-09-11 01:41:53 +0000
commitb2d2cb4a314e4d084d7d726752c93afb18c55b4e (patch)
tree24ee4130fba5835617cabe2d3f479a4bc8cce65d /django
parent3444b065bae2261b66c6c757683c64f8e8fae532 (diff)
Improved unicode-type, ASCII-convertible header handling in
HttpResponse. Fixed #8765. Thanks to SmileyChris and semenov for working on this one. git-svn-id: http://code.djangoproject.com/svn/django/trunk@13740 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django')
-rw-r--r--django/http/__init__.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/django/http/__init__.py b/django/http/__init__.py
index c3917a16b2..e585a713de 100644
--- a/django/http/__init__.py
+++ b/django/http/__init__.py
@@ -303,13 +303,16 @@ class HttpResponse(object):
def __init__(self, content='', mimetype=None, status=None,
content_type=None):
- from django.conf import settings
+ # _headers is a mapping of the lower-case name to the original case of
+ # the header (required for working with legacy systems) and the header
+ # value. Both the name of the header and its value are ASCII strings.
+ self._headers = {}
self._charset = settings.DEFAULT_CHARSET
if mimetype:
content_type = mimetype # For backwards compatibility
if not content_type:
content_type = "%s; charset=%s" % (settings.DEFAULT_CONTENT_TYPE,
- settings.DEFAULT_CHARSET)
+ self._charset)
if not isinstance(content, basestring) and hasattr(content, '__iter__'):
self._container = content
self._is_string = False
@@ -320,10 +323,7 @@ class HttpResponse(object):
if status:
self.status_code = status
- # _headers is a mapping of the lower-case name to the original case of
- # the header (required for working with legacy systems) and the header
- # value.
- self._headers = {'content-type': ('Content-Type', content_type)}
+ self['Content-Type'] = content_type
def __str__(self):
"""Full HTTP message, including headers."""