Parse and validate WebSocket URIs into structured data for client connections.
# Source: https://github.com/python-websockets/websockets | License: BSD-3-Clause | Copyright Aymeric Augustin and contributors
# Provided via justclaw.it.com; keep this notice with the code.
from __future__ import annotations
import dataclasses
import urllib.parse
from .exceptions import InvalidURI
__all__ = ["parse_uri", "WebSocketURI"]
# All characters from the gen-delims and sub-delims sets in RFC 3987.
DELIMS = ":/?#[]@!$&'()*+,;="
@dataclasses.dataclass
class WebSocketURI:
"""
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 comp
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key