MCPcopy Index your code
hub / github.com/RustPython/RustPython / _parse_proxy

Function _parse_proxy

Lib/urllib/request.py:727–758  ·  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

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