From 9124c528a8972468ee39ada0ea1520c081b53cb2 Mon Sep 17 00:00:00 2001 From: echel0n Date: Sat, 29 Mar 2014 22:02:32 -0700 Subject: [PATCH] Fixed couple bugs in cache control --- lib/cachecontrol/controller.py | 2 +- lib/cachecontrol/session.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/cachecontrol/controller.py b/lib/cachecontrol/controller.py index fbda9482..ca9f8be0 100644 --- a/lib/cachecontrol/controller.py +++ b/lib/cachecontrol/controller.py @@ -225,7 +225,7 @@ class CacheController(object): # cache when there is a max-age > 0 if cc and cc.get('max-age'): if int(cc['max-age']) > 0: - if isinstance(cache_max_age, (int, long)): + if isinstance(cache_max_age, (int)): cc['max-age'] = int(cache_max_age) resp.headers['cache-control'] = ''.join(['%s=%s' % (key, value) for (key, value) in cc.items()]) self.cache.set(cache_url, resp) diff --git a/lib/cachecontrol/session.py b/lib/cachecontrol/session.py index 99337991..1758cd6b 100644 --- a/lib/cachecontrol/session.py +++ b/lib/cachecontrol/session.py @@ -7,17 +7,17 @@ class CacheControlSession(Session): def get(self, *args, **kw): # auto-cache response self.cache_auto = False - if kw.has_key('cache_auto'): + if kw.get('cache_auto'): self.cache_auto = kw.pop('cache_auto') # urls allowed to cache self.cache_urls = [] - if kw.has_key('cache_urls'): + if kw.get('cache_urls'): self.cache_urls = [str(args[0])] + kw.pop('cache_urls') # timeout for cached responses self.cache_max_age = None - if kw.has_key('cache_max_age'): + if kw.get('cache_max_age'): self.cache_max_age = int(kw.pop('cache_max_age')) return super(CacheControlSession, self).get(*args, **kw)