diff options
| author | Keryn Knight <keryn@kerynknight.com> | 2022-02-09 14:31:42 +0000 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2022-03-02 20:23:39 +0100 |
| commit | e0b197c63c7e11352305bc9d8a408309e67dcea6 (patch) | |
| tree | 791900033a2026f0ee66cff898cb4f6636b3fbe1 /django/http | |
| parent | 9bde906fb2b8f63f056284347c660a3fec92ef34 (diff) | |
Refs #33546 -- Avoided unpacking data in ResponseHeaders when not necessary.
Diffstat (limited to 'django/http')
| -rw-r--r-- | django/http/response.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/django/http/response.py b/django/http/response.py index e40f2d169b..fb379f98a7 100644 --- a/django/http/response.py +++ b/django/http/response.py @@ -33,8 +33,9 @@ class ResponseHeaders(CaseInsensitiveMapping): correctly encoded. """ self._store = {} - for header, value in self._unpack_items(data): - self[header] = value + if data: + for header, value in self._unpack_items(data): + self[header] = value def _convert_to_charset(self, value, charset, mime_encode=False): """ @@ -98,7 +99,7 @@ class HttpResponseBase: def __init__( self, content_type=None, status=None, reason=None, charset=None, headers=None ): - self.headers = ResponseHeaders(headers or {}) + self.headers = ResponseHeaders(headers) self._charset = charset if content_type and "Content-Type" in self.headers: raise ValueError( |
