1
0
mirror of https://github.com/moparisthebest/SickRage synced 2024-08-13 16:53:54 -04:00
SickRage/lib/cachecontrol/session.py

24 lines
791 B
Python
Raw Normal View History

import datetime
from requests.sessions import Session
class CacheControlSession(Session):
def __init__(self, *args, **kw):
super(CacheControlSession, self).__init__(*args, **kw)
def request(self, *args, **kw):
# auto-cache response
self.cache_auto = False
if kw.has_key('cache_auto'):
self.cache_auto = kw.pop('cache_auto')
# urls allowed to cache
self.cache_urls = []
if kw.has_key('cache_urls'):
self.cache_urls = [str(args[1])] + kw.pop('cache_urls')
# timeout for cacheed responses
self.cache_max_age = None
if kw.has_key('cache_max_age'):
self.cache_max_age = int(kw.pop('cache_max_age'))
return super(CacheControlSession, self).request(*args, **kw)