Given a url with authentication components, extract them into a tuple of username,password. :rtype: (str,str)
(url: str)
| 1068 | |
| 1069 | |
| 1070 | def 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 | |
| 1087 | def check_header_validity(header: tuple[str | bytes, str | bytes]) -> None: |
no outgoing calls