MCPcopy Index your code
hub / github.com/python-websockets/websockets / parse_token

Function parse_token

src/websockets/headers.py:106–119  ·  view source on GitHub ↗

Parse a token from ``header`` at the given position. Return the token value and the new position. Raises: InvalidHeaderFormat: On invalid inputs.

(header: str, pos: int, header_name: str)

Source from the content-addressed store, hash-verified

104
105
106def parse_token(header: str, pos: int, header_name: str) -> tuple[str, int]:
107 """
108 Parse a token from ``header`` at the given position.
109
110 Return the token value and the new position.
111
112 Raises:
113 InvalidHeaderFormat: On invalid inputs.
114
115 """
116 match = _token_re.match(header, pos)
117 if match is None:
118 raise InvalidHeaderFormat(header_name, "expected token", header, pos)
119 return match.group(), match.end()
120
121
122_quoted_string_re = re.compile(

Callers 5

parse_connection_optionFunction · 0.85
parse_extension_itemFunction · 0.85
parse_subprotocol_itemFunction · 0.85

Calls 1

InvalidHeaderFormatClass · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…