Added check for ratelimit headers for GHE compatibility. #issue-984
@@ -527,6 +527,7 @@ class GitHubRepoProvider(RepoProvider):
elif (
e.code == 403
and e.response
+ and 'x-ratelimit-remaining' in e.response.headers
and e.response.headers.get('x-ratelimit-remaining') == '0'
):
rate_limit = e.response.headers['x-ratelimit-limit']
@@ -551,6 +552,7 @@ class GitHubRepoProvider(RepoProvider):
else:
raise
+ if 'x-ratelimit-remaining' in resp.headers:
# record and log github rate limit
remaining = int(resp.headers['x-ratelimit-remaining'])
rate_limit = int(resp.headers['x-ratelimit-limit'])
@@ -573,6 +575,7 @@ class GitHubRepoProvider(RepoProvider):
log("GitHub rate limit remaining {remaining}/{limit}. Reset in {delta}.".format(
remaining=remaining, limit=rate_limit, delta=delta,
))
+
return resp
@gen.coroutine
