MCPcopy Index your code
hub / github.com/python/cpython / read1

Method read1

Lib/http/client.py:678–695  ·  view source on GitHub ↗

Read with at most one underlying system call. If at least one byte is buffered, return that instead.

(self, n=-1)

Source from the content-addressed store, hash-verified

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

Callers 4

test_chunkedMethod · 0.95
_read1_chunkedMethod · 0.45

Calls 2

_read1_chunkedMethod · 0.95
_close_connMethod · 0.95

Tested by 3

test_chunkedMethod · 0.76