Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #14020 -- Made the `HttpResponse` class slightly more behave li…

…ke a dictionary, allowing the alternative argument to be unset. Serious thanks to schmichael and moopet.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@16417 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit dfa29161e2eff676eb4aa187f76c157556dfc5db 1 parent 22529d4
Jannis Leidel authored June 16, 2011
2  django/http/__init__.py
@@ -615,7 +615,7 @@ def has_header(self, header):
615 615
     def items(self):
616 616
         return self._headers.values()
617 617
 
618  
-    def get(self, header, alternate):
  618
+    def get(self, header, alternate=None):
619 619
         return self._headers.get(header.lower(), (None, alternate))[1]
620 620
 
621 621
     def set_cookie(self, key, value='', max_age=None, expires=None, path='/',
7  tests/regressiontests/httpwrappers/tests.py
@@ -243,6 +243,13 @@ def test_newlines_in_headers(self):
243 243
         self.assertRaises(BadHeaderError, r.__setitem__, 'test\rstr', 'test')
244 244
         self.assertRaises(BadHeaderError, r.__setitem__, 'test\nstr', 'test')
245 245
 
  246
+    def test_dict_behavior(self):
  247
+        """
  248
+        Test for bug #14020: Make HttpResponse.get work like dict.get
  249
+        """
  250
+        r = HttpResponse()
  251
+        self.assertEqual(r.get('test'), None)
  252
+
246 253
 class CookieTests(unittest.TestCase):
247 254
     def test_encode(self):
248 255
         """

0 notes on commit dfa2916

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