Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

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: bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
1 parent 22529d4 commit dfa29161e2eff676eb4aa187f76c157556dfc5db @jezdez jezdez committed
2  django/http/
@@ -615,7 +615,7 @@ def has_header(self, header):
def items(self):
return self._headers.values()
- def get(self, header, alternate):
+ def get(self, header, alternate=None):
return self._headers.get(header.lower(), (None, alternate))[1]
def set_cookie(self, key, value='', max_age=None, expires=None, path='/',
7 tests/regressiontests/httpwrappers/
@@ -243,6 +243,13 @@ def test_newlines_in_headers(self):
self.assertRaises(BadHeaderError, r.__setitem__, 'test\rstr', 'test')
self.assertRaises(BadHeaderError, r.__setitem__, 'test\nstr', 'test')
+ def test_dict_behavior(self):
+ """
+ Test for bug #14020: Make HttpResponse.get work like dict.get
+ """
+ r = HttpResponse()
+ self.assertEqual(r.get('test'), None)
class CookieTests(unittest.TestCase):
def test_encode(self):

0 comments on commit dfa2916

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