Read with at most one underlying system call. If at least one byte is buffered, return that instead.
(self, n=-1)
| 676 | return n |
| 677 | |
| 678 | def read1(self, n=-1): |
| 679 | """Read with at most one underlying system call. If at least one |
| 680 | byte is buffered, return that instead. |
| 681 | """ |
| 682 | if self.fp is None or self._method == "HEAD": |
| 683 | return b"" |
| 684 | if self.chunked: |
| 685 | return self._read1_chunked(n) |
| 686 | if self.length is not None and (n < 0 or n > self.length): |
| 687 | n = self.length |
| 688 | result = self.fp.read1(n) |
| 689 | if not result and n: |
| 690 | self._close_conn() |
| 691 | elif self.length is not None: |
| 692 | self.length -= len(result) |
| 693 | if not self.length: |
| 694 | self._close_conn() |
| 695 | return result |
| 696 | |
| 697 | def peek(self, n=-1): |
| 698 | # Having this enables IOBase.readline() to read more than one |