Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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 authored September 14, 2007

Showing 1 changed file with 5 additions and 9 deletions. Show diff stats Hide diff stats

  1. 14  django/http/__init__.py
14  django/http/__init__.py
@@ -246,7 +246,7 @@ def __init__(self, content='', mimetype=None, status=None,
246 246
         else:
247 247
             self._container = [content]
248 248
             self._is_string = True
249  
-        self.headers = {'Content-Type': content_type}
  249
+        self.headers = {'content-type': content_type}
250 250
         self.cookies = SimpleCookie()
251 251
         if status:
252 252
             self.status_code = status
@@ -258,24 +258,20 @@ def __str__(self):
258 258
             + '\n\n' + self.content
259 259
 
260 260
     def __setitem__(self, header, value):
261  
-        self.headers[header] = value
  261
+        self.headers[header.lower()] = value
262 262
 
263 263
     def __delitem__(self, header):
264 264
         try:
265  
-            del self.headers[header]
  265
+            del self.headers[header.lower()]
266 266
         except KeyError:
267 267
             pass
268 268
 
269 269
     def __getitem__(self, header):
270  
-        return self.headers[header]
  270
+        return self.headers[header.lower()]
271 271
 
272 272
     def has_header(self, header):
273 273
         "Case-insensitive check for a header"
274  
-        header = header.lower()
275  
-        for key in self.headers.keys():
276  
-            if key.lower() == header:
277  
-                return True
278  
-        return False
  274
+	return self.headers.has_key(header.lower())
279 275
 
280 276
     def set_cookie(self, key, value='', max_age=None, expires=None, path='/', domain=None, secure=None):
281 277
         self.cookies[key] = value

0 notes on commit 3da4c0a

Please sign in to comment.
Something went wrong with that request. Please try again.