MCPcopy Index your code
hub / github.com/python/cpython / _parse_proxy

Function _parse_proxy

Lib/urllib/request.py:729–760  ·  view source on GitHub ↗

Return (scheme, user, password, host/port) given a URL or an authority. If a URL is supplied, it must have an authority (host:port) component. According to RFC 3986, having an authority component means the URL must have two slashes after the scheme.

(proxy)

Source from the content-addressed store, hash-verified

727
728
729def _parse_proxy(proxy):
730 """Return (scheme, user, password, host/port) given a URL or an authority.
731
732 If a URL is supplied, it must have an authority (host:port) component.
733 According to RFC 3986, having an authority component means the URL must
734 have two slashes after the scheme.
735 """
736 scheme, r_scheme = _splittype(proxy)
737 if not r_scheme.startswith("/"):
738 # authority
739 scheme = None
740 authority = proxy
741 else:
742 # URL
743 if not r_scheme.startswith("//"):
744 raise ValueError("proxy URL with no authority: %r" % proxy)
745 # We have an authority, so for RFC 3986-compliant URLs (by ss 3.
746 # and 3.3.), path is empty or starts with '/'
747 if '@' in r_scheme:
748 host_separator = r_scheme.find('@')
749 end = r_scheme.find("/", host_separator)
750 else:
751 end = r_scheme.find("/", 2)
752 if end == -1:
753 end = None
754 authority = r_scheme[2:end]
755 userinfo, hostport = _splituser(authority)
756 if userinfo is not None:
757 user, password = _splitpasswd(userinfo)
758 else:
759 user = password = None
760 return scheme, user, password, hostport
761
762class ProxyHandler(BaseHandler):
763 # Proxies must be in front

Callers 2

test_parse_proxyMethod · 0.90
proxy_openMethod · 0.85

Calls 5

_splittypeFunction · 0.90
_splituserFunction · 0.90
_splitpasswdFunction · 0.90
startswithMethod · 0.45
findMethod · 0.45

Tested by 1

test_parse_proxyMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…