This commit is contained in:
Michael Lazar
2017-09-13 01:58:59 -04:00
parent ef0bd42963
commit 8c22d742f2

View File

@@ -233,16 +233,16 @@ class OAuthHelper(object):
def fix_cache(func): def fix_cache(func):
def wraps(self, _cache_key, _cache_ignore, *args, **kwargs): def wraps(self, _cache_key, _cache_ignore, *args, **kwargs):
if _cache_key: if _cache_key:
# Remove the request's session cookies from the cache key. # Pop the request's session cookies from the cache key.
# These appear to be unreliable and change with every # These appear to be unreliable and change with every
# request. Also, with the introduction of OAuth I don't think # request. Also, with the introduction of OAuth I don't think
# that cookies are being used to store anything that # that cookies are being used to store anything that
# differentiates requests anymore # differentiates API requests anyways
url, items = _cache_key url, items = _cache_key
_cache_key = (url, (items[0], items[1], items[3], items[4])) _cache_key = (url, (items[0], items[1], items[3], items[4]))
if kwargs['request'].method != 'GET': if kwargs['request'].method != 'GET':
# Why were POST/PUT/DELETE requests ever cached??? # Why were POST/PUT/DELETE requests ever being cached???
_cache_ignore = True _cache_ignore = True
return func(self, _cache_key, _cache_ignore, *args, **kwargs) return func(self, _cache_key, _cache_ignore, *args, **kwargs)
@@ -311,8 +311,7 @@ class OAuthRateLimitHandler(DefaultHandler):
else: else:
self.next_request_timestamp = None self.next_request_timestamp = None
@fix_cache @fix_cache(DefaultHandler.with_cache)
@DefaultHandler.with_cache
def request(self, request, proxies, timeout, verify, **_): def request(self, request, proxies, timeout, verify, **_):
settings = self.http.merge_environment_settings( settings = self.http.merge_environment_settings(
@@ -322,4 +321,4 @@ class OAuthRateLimitHandler(DefaultHandler):
response = self.http.send( response = self.http.send(
request, timeout=timeout, allow_redirects=False, **settings) request, timeout=timeout, allow_redirects=False, **settings)
self.update(response.headers) self.update(response.headers)
return response return response