utils: consider all 2xx HTTP request results as success (#17827)

This commit is contained in:
Thomas NOËL 2017-07-28 01:53:04 +02:00
parent 5cf7d09d3f
commit 1f0eaa3057
1 changed files with 2 additions and 2 deletions

View File

@ -163,9 +163,9 @@ class Requests(RequestsSession):
url = sign_url(url, remote_service.get('secret'))
response = super(Requests, self).request(method, url, **kwargs)
if response.status_code != 200 and log_errors:
if log_errors and (response.status_code // 100 != 2):
logging.error('failed to %s %s (%s)', method, url, response.status_code)
if method == 'GET' and cache_duration and response.status_code == 200:
if method == 'GET' and cache_duration and (response.status_code // 100 == 2):
cache.set(cache_key, response.content, cache_duration)
return response