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

Function parse_extension_item

src/websockets/headers.py:338–360  ·  view source on GitHub ↗

Parse an extension definition from ``header`` at the given position. Return an ``(extension name, parameters)`` pair, where ``parameters`` is a list of ``(name, value)`` pairs, and the new position. Raises: InvalidHeaderFormat: On invalid inputs.

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

Source from the content-addressed store, hash-verified

336
337
338def parse_extension_item(
339 header: str, pos: int, header_name: str
340) -> tuple[ExtensionHeader, int]:
341 """
342 Parse an extension definition from ``header`` at the given position.
343
344 Return an ``(extension name, parameters)`` pair, where ``parameters`` is a
345 list of ``(name, value)`` pairs, and the new position.
346
347 Raises:
348 InvalidHeaderFormat: On invalid inputs.
349
350 """
351 # Extract extension name.
352 name, pos = parse_token(header, pos, header_name)
353 pos = parse_OWS(header, pos)
354 # Extract all parameters.
355 parameters = []
356 while peek_ahead(header, pos) == ";":
357 pos = parse_OWS(header, pos + 1)
358 parameter, pos = parse_extension_item_param(header, pos, header_name)
359 parameters.append(parameter)
360 return (cast(ExtensionName, name), parameters), pos
361
362
363def parse_extension(header: str) -> list[ExtensionHeader]:

Callers

nothing calls this directly

Calls 5

parse_tokenFunction · 0.85
parse_OWSFunction · 0.85
peek_aheadFunction · 0.85
appendMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…