Read n bytes. Args: n, int, the number of bytes to read. Returns: A string of length 'n', or less if EOF is reached.
(self, n=-1)
| 804 | self._stream.seek(begin) |
| 805 | |
| 806 | def read(self, n=-1): |
| 807 | """Read n bytes. |
| 808 | |
| 809 | Args: |
| 810 | n, int, the number of bytes to read. |
| 811 | |
| 812 | Returns: |
| 813 | A string of length 'n', or less if EOF is reached. |
| 814 | """ |
| 815 | # The data left available to read sits in [cur, end) |
| 816 | cur = self._stream.tell() |
| 817 | end = self._begin + self._chunksize |
| 818 | if n == -1 or cur + n > end: |
| 819 | n = end - cur |
| 820 | return self._stream.read(n) |
| 821 | |
| 822 | |
| 823 | class HttpRequest(object): |
no outgoing calls