| 704 | return self.fp.peek(n) |
| 705 | |
| 706 | def readline(self, limit=-1): |
| 707 | if self.fp is None or self._method == "HEAD": |
| 708 | return b"" |
| 709 | if self.chunked: |
| 710 | # Fallback to IOBase readline which uses peek() and read() |
| 711 | return super().readline(limit) |
| 712 | if self.length is not None and (limit < 0 or limit > self.length): |
| 713 | limit = self.length |
| 714 | result = self.fp.readline(limit) |
| 715 | if not result and limit: |
| 716 | self._close_conn() |
| 717 | elif self.length is not None: |
| 718 | self.length -= len(result) |
| 719 | if not self.length: |
| 720 | self._close_conn() |
| 721 | return result |
| 722 | |
| 723 | def _read1_chunked(self, n): |
| 724 | # Strictly speaking, _get_chunk_left() may cause more than one read, |