summaryrefslogtreecommitdiff
path: root/django/http/response.py
diff options
context:
space:
mode:
Diffstat (limited to 'django/http/response.py')
-rw-r--r--django/http/response.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/django/http/response.py b/django/http/response.py
index 3edf10d1e8..2735e3c59d 100644
--- a/django/http/response.py
+++ b/django/http/response.py
@@ -261,6 +261,11 @@ class HttpResponseBase(six.Iterator):
if httponly:
self.cookies[key]['httponly'] = True
+ def setdefault(self, key, value):
+ """Sets a header unless it has already been set."""
+ if key not in self:
+ self[key] = value
+
def set_signed_cookie(self, key, value, salt='', **kwargs):
value = signing.get_cookie_signer(salt=key + salt).sign(value)
return self.set_cookie(key, value, **kwargs)