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

Function parse_quoted_string

src/websockets/headers.py:130–143  ·  view source on GitHub ↗

Parse a quoted string from ``header`` at the given position. Return the unquoted 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

128
129
130def parse_quoted_string(header: str, pos: int, header_name: str) -> tuple[str, int]:
131 """
132 Parse a quoted string from ``header`` at the given position.
133
134 Return the unquoted value and the new position.
135
136 Raises:
137 InvalidHeaderFormat: On invalid inputs.
138
139 """
140 match = _quoted_string_re.match(header, pos)
141 if match is None:
142 raise InvalidHeaderFormat(header_name, "expected quoted string", header, pos)
143 return _unquote_re.sub(r"\1", match.group()[1:-1]), match.end()
144
145
146_quotable_re = re.compile(r"[\x09\x20-\x7e\x80-\xff]*")

Callers 1

Calls 1

InvalidHeaderFormatClass · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…