def _parse_http_proxy(envVarNames):
"""
Parses the value of the first existing environment variable named
in `envVarNames` into a host and port tuple where port is None if
it's not present in the environment variable.
"""
p = re.compile(r'(?:https?://)?([^:]+):?(\d+)?/?$')
for name in envVarNames:
value = get_env(name)
if value:
m = p.match(value)
if m:
return m.group(1), m.group(2)
else:
abort("Value of " + name + " is not valid: " + value)
return (None, None)
评论列表
文章目录