Read a line from buffer, returning (line, remaining_buffer).
(self, unreader, buf, limit=0)
| 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.""" |
no test coverage detected