MCPcopy
hub / github.com/benoitc/gunicorn / read_line

Method read_line

gunicorn/http/message.py:612–629  ·  view source on GitHub ↗

Read a line from buffer, returning (line, remaining_buffer).

(self, unreader, buf, limit=0)

Source from the content-addressed store, hash-verified

610 buf.extend(data)
611
612 def read_line(self, unreader, buf, limit=0):
613 """Read a line from buffer, returning (line, remaining_buffer)."""
614 data = bytes(buf)
615
616 while True:
617 idx = data.find(b"\r\n")
618 if idx >= 0:
619 # check if the request line is too large
620 if idx > limit > 0:
621 raise LimitRequestLine(idx, limit)
622 break
623 if len(data) - 2 > limit > 0:
624 raise LimitRequestLine(len(data), limit)
625 self.read_into(unreader, buf)
626 data = bytes(buf)
627
628 return (data[:idx], # request line,
629 bytearray(data[idx + 2:])) # residue in the buffer, skip \r\n
630
631 def read_bytes(self, unreader, buf, count):
632 """Read exactly count bytes from buffer/unreader."""

Callers 1

_parse_pythonMethod · 0.95

Calls 2

read_intoMethod · 0.95
LimitRequestLineClass · 0.90

Tested by

no test coverage detected