def get_host_info(self, host): x509 = {} if isinstance(host, tuple): host, x509 = host auth, host = urllib_parse.splituser(host) if auth: auth = urllib_parse.unquote_to_bytes(auth) auth = base64.encodebytes(auth).decode("utf-8") auth = "".join(auth.split()) # get rid of whitespace extra_headers = [("Authorization", "Basic " + auth)] else: extra_headers = [] return host, extra_headers, x509