This commit is contained in:
Jack Robison 2019-02-28 12:42:23 -05:00
parent 10d73fe480
commit f52e44b56a
No known key found for this signature in database
GPG key ID: DF25C68FE0239BB2

View file

@ -163,14 +163,14 @@ async def resolve_host(url: str, port: int, proto: str) -> str:
))[0][4][0]
def get_ssl_context():
def get_ssl_context() -> ssl.SSLContext:
return ssl.create_default_context(
purpose=ssl.Purpose.CLIENT_AUTH, capath=None if 'darwin' not in sys.platform else certifi.where()
)
@contextlib.asynccontextmanager
async def aiohttp_request(method, url, **kwargs):
async def aiohttp_request(method, url, **kwargs) -> typing.AsyncContextManager[aiohttp.ClientResponse]:
async with aiohttp.ClientSession() as session:
async with session.request(method, url, ssl=get_ssl_context(), **kwargs) as response:
yield response