mirror of
https://github.com/kennethreitz/requests.git
synced 2026-06-05 14:50:16 +00:00
session improvements
Signed-off-by: Kenneth Reitz <me@kennethreitz.org>
This commit is contained in:
+4
-11
@@ -353,7 +353,7 @@ class Session(SessionRedirectMixin):
|
||||
>>> s.get('http://httpbin.org/get')
|
||||
<Response [200]>
|
||||
"""
|
||||
__attrs__ = [
|
||||
__slots__ = [
|
||||
'headers',
|
||||
'cookies',
|
||||
'auth',
|
||||
@@ -369,6 +369,8 @@ class Session(SessionRedirectMixin):
|
||||
'max_redirects',
|
||||
]
|
||||
|
||||
__slots__
|
||||
|
||||
def __init__(self):
|
||||
# : A case-insensitive dictionary of headers to be sent on each
|
||||
#: :class:`Request <Request>` sent from this
|
||||
@@ -735,18 +737,9 @@ class Session(SessionRedirectMixin):
|
||||
self.adapters[key] = self.adapters.pop(key)
|
||||
|
||||
def __getstate__(self):
|
||||
state = {attr: getattr(self, attr, None) for attr in self.__attrs__}
|
||||
state = {attr: getattr(self, attr, None) for attr in self.__slots__}
|
||||
return state
|
||||
|
||||
def __setstate__(self, state):
|
||||
for attr, value in state.items():
|
||||
setattr(self, attr, value)
|
||||
|
||||
|
||||
def session():
|
||||
"""
|
||||
Returns a :class:`Session` for context-management.
|
||||
|
||||
:rtype: Session
|
||||
"""
|
||||
return Session()
|
||||
|
||||
@@ -37,7 +37,6 @@ class CaseInsensitiveDict(collections.MutableMapping):
|
||||
operations are given keys that have equal ``.lower()``s, the
|
||||
behavior is undefined.
|
||||
"""
|
||||
|
||||
__slots__ = ('_store')
|
||||
|
||||
def __init__(self, data=None, **kwargs):
|
||||
@@ -98,7 +97,6 @@ class HTTPHeaderDict(CaseInsensitiveDict):
|
||||
self.extend({} if data is None else data, **kwargs)
|
||||
|
||||
|
||||
#
|
||||
# We'll store tuples in the internal dictionary, but present them as a
|
||||
# concatenated string when we use item access methods.
|
||||
#
|
||||
|
||||
Reference in New Issue
Block a user