summaryrefslogtreecommitdiff
path: root/pip/_vendor/requests/packages/urllib3/_collections.py
diff options
context:
space:
mode:
authorCory Benfield <lukasaoz@gmail.com>2015-03-15 12:08:47 +0000
committerCory Benfield <lukasaoz@gmail.com>2015-03-15 12:08:47 +0000
commit91183b5cf80c81e8d963c57e365650772af4ce03 (patch)
treeb9a310092858db92039d053675e4f44fa159c086 /pip/_vendor/requests/packages/urllib3/_collections.py
parent5a32a4d34a937e90d076793f125a73253320da3e (diff)
downloadpip-91183b5cf80c81e8d963c57e365650772af4ce03.tar.gz
Upgrade requests to 2.6.0.
Also brings urllib3 to 43b5b2b452e4344374de7d08ececcca495079b8d
Diffstat (limited to 'pip/_vendor/requests/packages/urllib3/_collections.py')
-rw-r--r--pip/_vendor/requests/packages/urllib3/_collections.py27
1 files changed, 14 insertions, 13 deletions
diff --git a/pip/_vendor/requests/packages/urllib3/_collections.py b/pip/_vendor/requests/packages/urllib3/_collections.py
index 06412ddf3..cc424de0f 100644
--- a/pip/_vendor/requests/packages/urllib3/_collections.py
+++ b/pip/_vendor/requests/packages/urllib3/_collections.py
@@ -20,8 +20,6 @@ from .packages.six import iterkeys, itervalues, PY3
__all__ = ['RecentlyUsedContainer', 'HTTPHeaderDict']
-MULTIPLE_HEADERS_ALLOWED = frozenset(['cookie', 'set-cookie', 'set-cookie2'])
-
_Null = object()
@@ -143,7 +141,10 @@ class HTTPHeaderDict(dict):
def __init__(self, headers=None, **kwargs):
dict.__init__(self)
if headers is not None:
- self.extend(headers)
+ if isinstance(headers, HTTPHeaderDict):
+ self._copy_from(headers)
+ else:
+ self.extend(headers)
if kwargs:
self.extend(kwargs)
@@ -223,11 +224,8 @@ class HTTPHeaderDict(dict):
vals.append(val)
else:
# vals should be a tuple then, i.e. only one item so far
- if key_lower in MULTIPLE_HEADERS_ALLOWED:
- # Need to convert the tuple to list for further extension
- _dict_setitem(self, key_lower, [vals[0], vals[1], val])
- else:
- _dict_setitem(self, key_lower, new_vals)
+ # Need to convert the tuple to list for further extension
+ _dict_setitem(self, key_lower, [vals[0], vals[1], val])
def extend(*args, **kwargs):
"""Generic import function for any type of header-like object.
@@ -276,14 +274,17 @@ class HTTPHeaderDict(dict):
def __repr__(self):
return "%s(%s)" % (type(self).__name__, dict(self.itermerged()))
- def copy(self):
- clone = type(self)()
- for key in self:
- val = _dict_getitem(self, key)
+ def _copy_from(self, other):
+ for key in other:
+ val = _dict_getitem(other, key)
if isinstance(val, list):
# Don't need to convert tuples
val = list(val)
- _dict_setitem(clone, key, val)
+ _dict_setitem(self, key, val)
+
+ def copy(self):
+ clone = type(self)()
+ clone._copy_from(self)
return clone
def iteritems(self):