mirror of
https://github.com/pypa/pip
synced 2023-12-13 21:30:23 +01:00
Update CacheControl to 0.12.6
This commit is contained in:
parent
0e1e0ef566
commit
ac42c232ce
|
@ -4,7 +4,7 @@ Make it easy to import from cachecontrol without long namespaces.
|
||||||
"""
|
"""
|
||||||
__author__ = "Eric Larson"
|
__author__ = "Eric Larson"
|
||||||
__email__ = "eric@ionrock.org"
|
__email__ = "eric@ionrock.org"
|
||||||
__version__ = "0.12.5"
|
__version__ = "0.12.6"
|
||||||
|
|
||||||
from .wrapper import CacheControl
|
from .wrapper import CacheControl
|
||||||
from .adapter import CacheControlAdapter
|
from .adapter import CacheControlAdapter
|
||||||
|
|
|
@ -24,7 +24,7 @@ class CacheControlAdapter(HTTPAdapter):
|
||||||
**kw
|
**kw
|
||||||
):
|
):
|
||||||
super(CacheControlAdapter, self).__init__(*args, **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.heuristic = heuristic
|
||||||
self.cacheable_methods = cacheable_methods or ("GET",)
|
self.cacheable_methods = cacheable_methods or ("GET",)
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ class CacheController(object):
|
||||||
def __init__(
|
def __init__(
|
||||||
self, cache=None, cache_etags=True, serializer=None, status_codes=None
|
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.cache_etags = cache_etags
|
||||||
self.serializer = serializer or Serializer()
|
self.serializer = serializer or Serializer()
|
||||||
self.cacheable_status_codes = status_codes or (200, 203, 300, 301)
|
self.cacheable_status_codes = status_codes or (200, 203, 300, 301)
|
||||||
|
@ -293,6 +293,15 @@ class CacheController(object):
|
||||||
if no_store:
|
if no_store:
|
||||||
return
|
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 we've been given an etag, then keep the response
|
||||||
if self.cache_etags and "etag" in response_headers:
|
if self.cache_etags and "etag" in response_headers:
|
||||||
logger.debug("Caching due to etag")
|
logger.debug("Caching due to etag")
|
||||||
|
|
|
@ -107,6 +107,8 @@ class Serializer(object):
|
||||||
"""
|
"""
|
||||||
# Special case the '*' Vary value as it means we cannot actually
|
# Special case the '*' Vary value as it means we cannot actually
|
||||||
# determine if the cached response is suitable for this request.
|
# 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", {}):
|
if "*" in cached.get("vary", {}):
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -179,7 +181,7 @@ class Serializer(object):
|
||||||
|
|
||||||
def _loads_v4(self, request, data):
|
def _loads_v4(self, request, data):
|
||||||
try:
|
try:
|
||||||
cached = msgpack.loads(data, encoding="utf-8")
|
cached = msgpack.loads(data, raw=False)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ def CacheControl(
|
||||||
cacheable_methods=None,
|
cacheable_methods=None,
|
||||||
):
|
):
|
||||||
|
|
||||||
cache = cache or DictCache()
|
cache = DictCache() if cache is None else cache
|
||||||
adapter_class = adapter_class or CacheControlAdapter
|
adapter_class = adapter_class or CacheControlAdapter
|
||||||
adapter = adapter_class(
|
adapter = adapter_class(
|
||||||
cache,
|
cache,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
appdirs==1.4.3
|
appdirs==1.4.3
|
||||||
CacheControl==0.12.5
|
CacheControl==0.12.6
|
||||||
colorama==0.4.1
|
colorama==0.4.1
|
||||||
contextlib2==0.6.0
|
contextlib2==0.6.0
|
||||||
distlib==0.2.9.post0
|
distlib==0.2.9.post0
|
||||||
|
|
Loading…
Reference in a new issue