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,
|
|
|
|
heuristic=None):
|
|
|
|
|
2014-03-27 21:06:03 +00:00
|
|
|
cache = cache or DictCache()
|
2014-04-23 06:24:08 +00:00
|
|
|
adapter = CacheControlAdapter(
|
|
|
|
cache,
|
|
|
|
cache_etags=cache_etags,
|
|
|
|
serializer=serializer,
|
2015-04-28 17:32:10 +00:00
|
|
|
heuristic=heuristic,
|
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
|