mirror of
https://github.com/django/django.git
synced 2025-02-28 19:44:35 +00:00
Fixed #2970: made HttpResponse headers case-insensitive. Thanks to SmileyChris for the original patch and PhiR for the final one.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@6212 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
ad077ccbc0
commit
3da4c0ab92
@ -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
|
||||||
@ -258,24 +258,20 @@ class HttpResponse(object):
|
|||||||
+ '\n\n' + self.content
|
+ '\n\n' + self.content
|
||||||
|
|
||||||
def __setitem__(self, header, value):
|
def __setitem__(self, header, value):
|
||||||
self.headers[header] = value
|
self.headers[header.lower()] = value
|
||||||
|
|
||||||
def __delitem__(self, header):
|
def __delitem__(self, header):
|
||||||
try:
|
try:
|
||||||
del self.headers[header]
|
del self.headers[header.lower()]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def __getitem__(self, header):
|
def __getitem__(self, header):
|
||||||
return self.headers[header]
|
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"
|
||||||
header = header.lower()
|
return self.headers.has_key(header.lower())
|
||||||
for key in self.headers.keys():
|
|
||||||
if key.lower() == header:
|
|
||||||
return True
|
|
||||||
return False
|
|
||||||
|
|
||||||
def set_cookie(self, key, value='', max_age=None, expires=None, path='/', domain=None, secure=None):
|
def set_cookie(self, key, value='', max_age=None, expires=None, path='/', domain=None, secure=None):
|
||||||
self.cookies[key] = value
|
self.cookies[key] = value
|
||||||
|
Loading…
x
Reference in New Issue
Block a user