本文整理匯總了Python中future.backports.urllib.parse.splituser方法的典型用法代碼示例。如果您正苦於以下問題:Python parse.splituser方法的具體用法?Python parse.splituser怎麽用?Python parse.splituser使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類future.backports.urllib.parse
的用法示例。
在下文中一共展示了parse.splituser方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get_host_info
# 需要導入模塊: from future.backports.urllib import parse [as 別名]
# 或者: from future.backports.urllib.parse import splituser [as 別名]
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
##
# Connect to server.
#
# @param host Target host.
# @return An HTTPConnection object