diff --git a/lib/cachecontrol/adapter.py b/lib/cachecontrol/adapter.py index 9bc25c22..264fb1be 100644 --- a/lib/cachecontrol/adapter.py +++ b/lib/cachecontrol/adapter.py @@ -2,13 +2,14 @@ from requests.adapters import HTTPAdapter from cachecontrol.controller import CacheController from cachecontrol.cache import DictCache - +from cachecontrol.session import CacheControlSession class CacheControlAdapter(HTTPAdapter): invalidating_methods = set(['PUT', 'DELETE']) def __init__(self, sess=None, cache=None, cache_etags=True, *args, **kw): super(CacheControlAdapter, self).__init__(*args, **kw) + self.sess = sess or CacheControlSession() self.cache = cache or DictCache() self.controller = CacheController(sess=sess, cache=cache, cache_etags=cache_etags) diff --git a/lib/cachecontrol/controller.py b/lib/cachecontrol/controller.py index 680479a3..9dfea3cc 100644 --- a/lib/cachecontrol/controller.py +++ b/lib/cachecontrol/controller.py @@ -8,7 +8,7 @@ import datetime from cachecontrol.cache import DictCache from cachecontrol.compat import parsedate_tz - +from cachecontrol.session import CacheControlSession URI = re.compile(r"^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?") @@ -28,7 +28,7 @@ class CacheController(object): def __init__(self, sess=None, cache=None, cache_etags=True): self.cache = cache or DictCache() self.cache_etags = cache_etags - self.sess = sess + self.sess = sess or CacheControlSession() def _urlnorm(self, uri): """Normalize the URL to create a safe key for the cache"""