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

Function parse_line

src/websockets/http11.py:302–326  ·  view source on GitHub ↗

Parse a single line. CRLF is stripped from the return value. Args: read_line: Generator-based coroutine that reads a LF-terminated line or raises an exception if there isn't enough data. Raises: EOFError: If the connection is closed without a CRLF.

(
    read_line: Callable[[int], Generator[None, None, bytes | bytearray]],
)

Source from the content-addressed store, hash-verified

300
301
302def parse_line(
303 read_line: Callable[[int], Generator[None, None, bytes | bytearray]],
304) -> Generator[None, None, bytes | bytearray]:
305 """
306 Parse a single line.
307
308 CRLF is stripped from the return value.
309
310 Args:
311 read_line: Generator-based coroutine that reads a LF-terminated line
312 or raises an exception if there isn't enough data.
313
314 Raises:
315 EOFError: If the connection is closed without a CRLF.
316 SecurityError: If the response exceeds a security limit.
317
318 """
319 try:
320 line = yield from read_line(MAX_LINE_LENGTH)
321 except RuntimeError:
322 raise SecurityError("line too long")
323 # Not mandatory but safe - https://datatracker.ietf.org/doc/html/rfc7230#section-3.5
324 if not line.endswith(b"\r\n"):
325 raise EOFError("line without CRLF")
326 return line[:-2]
327
328
329def parse_headers(

Callers 4

parseMethod · 0.85
parseMethod · 0.85
parse_headersFunction · 0.85
read_bodyFunction · 0.85

Calls 2

read_lineFunction · 0.85
SecurityErrorClass · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…