Backwards-incompatible change: renamed HttpResponse.headers to HttpResponse._headers to deliberately break anyone accessing headers directly instead of through the case-insensitive proxies on HttpResponse itself. See BackwardsIncompatibleChanges for more details.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@6225 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
8cf9a6d64b
commit
dd799591fc
|
@ -246,7 +246,7 @@ class HttpResponse(object):
|
||||||
else:
|
else:
|
||||||
self._container = [content]
|
self._container = [content]
|
||||||
self._is_string = True
|
self._is_string = True
|
||||||
self.headers = {'content-type': content_type}
|
self._headers = {'content-type': content_type}
|
||||||
self.cookies = SimpleCookie()
|
self.cookies = SimpleCookie()
|
||||||
if status:
|
if status:
|
||||||
self.status_code = status
|
self.status_code = status
|
||||||
|
@ -254,24 +254,24 @@ class HttpResponse(object):
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
"Full HTTP message, including headers"
|
"Full HTTP message, including headers"
|
||||||
return '\n'.join(['%s: %s' % (key, value)
|
return '\n'.join(['%s: %s' % (key, value)
|
||||||
for key, value in self.headers.items()]) \
|
for key, value in self._headers.items()]) \
|
||||||
+ '\n\n' + self.content
|
+ '\n\n' + self.content
|
||||||
|
|
||||||
def __setitem__(self, header, value):
|
def __setitem__(self, header, value):
|
||||||
self.headers[header.lower()] = value
|
self._headers[header.lower()] = value
|
||||||
|
|
||||||
def __delitem__(self, header):
|
def __delitem__(self, header):
|
||||||
try:
|
try:
|
||||||
del self.headers[header.lower()]
|
del self._headers[header.lower()]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def __getitem__(self, header):
|
def __getitem__(self, header):
|
||||||
return self.headers[header.lower()]
|
return self._headers[header.lower()]
|
||||||
|
|
||||||
def has_header(self, header):
|
def has_header(self, header):
|
||||||
"Case-insensitive check for a header"
|
"Case-insensitive check for a header"
|
||||||
return self.headers.has_key(header.lower())
|
return self._headers.has_key(header.lower())
|
||||||
|
|
||||||
__contains__ = has_header
|
__contains__ = has_header
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue