Update CacheControl to 0.12.6

This commit is contained in:
Pradyun Gedam 2020-01-21 12:48:59 +05:30
parent 0e1e0ef566
commit ac42c232ce
No known key found for this signature in database
GPG Key ID: DA17C4B29CB32E4B
6 changed files with 17 additions and 6 deletions

View File

@ -4,7 +4,7 @@ Make it easy to import from cachecontrol without long namespaces.
"""
__author__ = "Eric Larson"
__email__ = "eric@ionrock.org"
__version__ = "0.12.5"
__version__ = "0.12.6"
from .wrapper import CacheControl
from .adapter import CacheControlAdapter

View File

@ -24,7 +24,7 @@ class CacheControlAdapter(HTTPAdapter):
**kw
):
super(CacheControlAdapter, self).__init__(*args, **kw)
self.cache = cache or DictCache()
self.cache = DictCache() if cache is None else cache
self.heuristic = heuristic
self.cacheable_methods = cacheable_methods or ("GET",)

View File

@ -34,7 +34,7 @@ class CacheController(object):
def __init__(
self, cache=None, cache_etags=True, serializer=None, status_codes=None
):
self.cache = cache or DictCache()
self.cache = DictCache() if cache is None else cache
self.cache_etags = cache_etags
self.serializer = serializer or Serializer()
self.cacheable_status_codes = status_codes or (200, 203, 300, 301)
@ -293,6 +293,15 @@ class CacheController(object):
if no_store:
return
# https://tools.ietf.org/html/rfc7234#section-4.1:
# A Vary header field-value of "*" always fails to match.
# Storing such a response leads to a deserialization warning
# during cache lookup and is not allowed to ever be served,
# so storing it can be avoided.
if "*" in response_headers.get("vary", ""):
logger.debug('Response header has "Vary: *"')
return
# If we've been given an etag, then keep the response
if self.cache_etags and "etag" in response_headers:
logger.debug("Caching due to etag")

View File

@ -107,6 +107,8 @@ class Serializer(object):
"""
# Special case the '*' Vary value as it means we cannot actually
# determine if the cached response is suitable for this request.
# This case is also handled in the controller code when creating
# a cache entry, but is left here for backwards compatibility.
if "*" in cached.get("vary", {}):
return
@ -179,7 +181,7 @@ class Serializer(object):
def _loads_v4(self, request, data):
try:
cached = msgpack.loads(data, encoding="utf-8")
cached = msgpack.loads(data, raw=False)
except ValueError:
return

View File

@ -13,7 +13,7 @@ def CacheControl(
cacheable_methods=None,
):
cache = cache or DictCache()
cache = DictCache() if cache is None else cache
adapter_class = adapter_class or CacheControlAdapter
adapter = adapter_class(
cache,

View File

@ -1,5 +1,5 @@
appdirs==1.4.3
CacheControl==0.12.5
CacheControl==0.12.6
colorama==0.4.1
contextlib2==0.6.0
distlib==0.2.9.post0