2014-04-23 06:24:08 +00:00
|
|
|
from .adapter import CacheControlAdapter
|
|
|
|
from .cache import DictCache
|
2014-03-27 21:06:03 +00:00
|
|
|
|
2015-04-28 17:32:10 +00:00
|
|
|
|
|
|
|
def CacheControl(sess,
|
|
|
|
cache=None,
|
|
|
|
cache_etags=True,
|
|
|
|
serializer=None,
|
2017-07-12 00:36:15 +00:00
|
|
|
heuristic=None,
|
|
|
|
controller_class=None,
|
|
|
|
adapter_class=None,
|
|
|
|
cacheable_methods=None):
|
2015-04-28 17:32:10 +00:00
|
|
|
|
2014-03-27 21:06:03 +00:00
|
|
|
cache = cache or DictCache()
|
2017-07-12 00:36:15 +00:00
|
|
|
adapter_class = adapter_class or CacheControlAdapter
|
|
|
|
adapter = adapter_class(
|
2014-04-23 06:24:08 +00:00
|
|
|
cache,
|
|
|
|
cache_etags=cache_etags,
|
|
|
|
serializer=serializer,
|
2015-04-28 17:32:10 +00:00
|
|
|
heuristic=heuristic,
|
2017-07-12 00:36:15 +00:00
|
|
|
controller_class=controller_class,
|
|
|
|
cacheable_methods=cacheable_methods
|
2014-04-23 06:24:08 +00:00
|
|
|
)
|
2014-03-27 21:06:03 +00:00
|
|
|
sess.mount('http://', adapter)
|
2014-04-23 06:24:08 +00:00
|
|
|
sess.mount('https://', adapter)
|
2014-03-27 21:06:03 +00:00
|
|
|
|
|
|
|
return sess
|