# -*- coding: utf-8 -*- from requests.adapters import HTTPAdapter class CustomHostnameHTTPSAdapter(HTTPAdapter): """Allow for setting a custom hostname on an adapter.""" def __init__(self, custom_hostname: str) -> None: self.custom_hostname = custom_hostname super().__init__() def cert_verify(self, conn, url, verify, cert): conn.assert_hostname = self.custom_hostname return super().cert_verify(conn, url, verify, cert)