From eb37c39c669f439e6ca5bb7abd0392769dc0d264 Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Thu, 15 Mar 2018 16:37:04 -0400 Subject: [PATCH] as_dict Signed-off-by: Kenneth Reitz --- requests/structures.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/requests/structures.py b/requests/structures.py index 1d2c2046..bbaa2070 100644 --- a/requests/structures.py +++ b/requests/structures.py @@ -196,11 +196,16 @@ class HTTPHeaderDict(CaseInsensitiveDict): else: self._extend(ik, tuple(iv)) - def __repr__(self): + @property + def _as_dict(self): + """A dictionary representation of the HTTPHeaderDict.""" d = {} for k, vals in self._store.values(): d[k] = vals[0] if len(vals) == 1 else vals - return repr(d) + return d + + def __repr__(self): + return repr(self._as_dict) class LookupDict(dict):