Add header support

This commit is contained in:
agatha 2023-11-10 19:42:16 -05:00
parent d00b009706
commit 8a9200e627

View File

@ -6,13 +6,15 @@ from requests.packages.urllib3.util.retry import Retry
class GitHubApi: class GitHubApi:
def __init__(self, proxy=None): def __init__(self, headers=None, proxy=None):
self.base_url = 'https://api.github.com' self.base_url = 'https://api.github.com'
self.session = requests.Session() self.session = requests.Session()
retries = Retry(total=3, backoff_factor=1) retries = Retry(total=3, backoff_factor=1)
self.session.mount('https://', HTTPAdapter(max_retries=retries)) self.session.mount('https://', HTTPAdapter(max_retries=retries))
if headers:
self.session.headers.update(headers)
if proxy: if proxy:
self.session.proxies.update(proxy) self.session.proxies.update(proxy)