Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed #2970: made HttpResponse headers case-insensitive. Thanks to Sm…

…ileyChris 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
  • Loading branch information...
commit 3da4c0ab9292e8e3378b7314174f0bbcc4e692d1 1 parent ad077cc
Jacob Kaplan-Moss jacobian authored
Showing with 5 additions and 9 deletions.
  1. +5 −9 django/http/__init__.py
14 django/http/__init__.py
View
@@ -246,7 +246,7 @@ def __init__(self, content='', mimetype=None, status=None,
else:
self._container = [content]
self._is_string = True
- self.headers = {'Content-Type': content_type}
+ self.headers = {'content-type': content_type}
self.cookies = SimpleCookie()
if status:
self.status_code = status
@@ -258,24 +258,20 @@ def __str__(self):
+ '\n\n' + self.content
def __setitem__(self, header, value):
- self.headers[header] = value
+ self.headers[header.lower()] = value
def __delitem__(self, header):
try:
- del self.headers[header]
+ del self.headers[header.lower()]
except KeyError:
pass
def __getitem__(self, header):
- return self.headers[header]
+ return self.headers[header.lower()]
def has_header(self, header):
"Case-insensitive check for a header"
- header = header.lower()
- for key in self.headers.keys():
- if key.lower() == header:
- return True
- return False
+ return self.headers.has_key(header.lower())
def set_cookie(self, key, value='', max_age=None, expires=None, path='/', domain=None, secure=None):
self.cookies[key] = value
Please sign in to comment.
Something went wrong with that request. Please try again.