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

Function parse_upgrade_protocol

src/websockets/headers.py:268–283  ·  view source on GitHub ↗

Parse an Upgrade protocol from ``header`` at the given position. Return the protocol 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

266
267
268def parse_upgrade_protocol(
269 header: str, pos: int, header_name: str
270) -> tuple[UpgradeProtocol, int]:
271 """
272 Parse an Upgrade protocol from ``header`` at the given position.
273
274 Return the protocol value and the new position.
275
276 Raises:
277 InvalidHeaderFormat: On invalid inputs.
278
279 """
280 match = _protocol_re.match(header, pos)
281 if match is None:
282 raise InvalidHeaderFormat(header_name, "expected protocol", header, pos)
283 return cast(UpgradeProtocol, match.group()), match.end()
284
285
286def parse_upgrade(header: str) -> list[UpgradeProtocol]:

Callers

nothing calls this directly

Calls 1

InvalidHeaderFormatClass · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…