MCPcopy
hub / github.com/psf/requests / get_auth_from_url

Function get_auth_from_url

src/requests/utils.py:1070–1084  ·  view source on GitHub ↗

Given a url with authentication components, extract them into a tuple of username,password. :rtype: (str,str)

(url: str)

Source from the content-addressed store, hash-verified

1068
1069
1070def get_auth_from_url(url: str) -> tuple[str, str]:
1071 """Given a url with authentication components, extract them into a tuple of
1072 username,password.
1073
1074 :rtype: (str,str)
1075 """
1076 parsed = urlparse(url)
1077
1078 try:
1079 # except handles parsed.username/password being None
1080 auth = (unquote(parsed.username), unquote(parsed.password)) # type: ignore[arg-type]
1081 except (AttributeError, TypeError):
1082 auth = ("", "")
1083
1084 return auth
1085
1086
1087def check_header_validity(header: tuple[str | bytes, str | bytes]) -> None:

Callers 5

test_get_auth_from_urlFunction · 0.90
prepare_authMethod · 0.85
proxy_manager_forMethod · 0.85
proxy_headersMethod · 0.85
rebuild_proxiesMethod · 0.85

Calls

no outgoing calls

Tested by 1

test_get_auth_from_urlFunction · 0.72