WebSocket URI. Attributes: secure: :obj:`True` for a ``wss`` URI, :obj:`False` for a ``ws`` URI. host: Normalized to lower case. port: Always set even if it's the default. path: May be empty. query: May be empty if the URI doesn't include a query com
| 15 | |
| 16 | @dataclasses.dataclass |
| 17 | class WebSocketURI: |
| 18 | """ |
| 19 | WebSocket URI. |
| 20 | |
| 21 | Attributes: |
| 22 | secure: :obj:`True` for a ``wss`` URI, :obj:`False` for a ``ws`` URI. |
| 23 | host: Normalized to lower case. |
| 24 | port: Always set even if it's the default. |
| 25 | path: May be empty. |
| 26 | query: May be empty if the URI doesn't include a query component. |
| 27 | username: Available when the URI contains `User Information`_. |
| 28 | password: Available when the URI contains `User Information`_. |
| 29 | |
| 30 | .. _User Information: https://datatracker.ietf.org/doc/html/rfc3986#section-3.2.1 |
| 31 | |
| 32 | """ |
| 33 | |
| 34 | secure: bool |
| 35 | host: str |
| 36 | port: int |
| 37 | path: str |
| 38 | query: str |
| 39 | username: str | None = None |
| 40 | password: str | None = None |
| 41 | |
| 42 | @property |
| 43 | def resource_name(self) -> str: |
| 44 | if self.path: |
| 45 | resource_name = self.path |
| 46 | else: |
| 47 | resource_name = "/" |
| 48 | if self.query: |
| 49 | resource_name += "?" + self.query |
| 50 | return resource_name |
| 51 | |
| 52 | @property |
| 53 | def user_info(self) -> tuple[str, str] | None: |
| 54 | if self.username is None: |
| 55 | return None |
| 56 | assert self.password is not None |
| 57 | return (self.username, self.password) |
| 58 | |
| 59 | |
| 60 | def parse_uri(uri: str) -> WebSocketURI: |
no outgoing calls
no test coverage detected
searching dependent graphs…