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

Method _readinto_chunked

Lib/http/client.py:619–641  ·  view source on GitHub ↗
(self, b)

Source from the content-addressed store, hash-verified

617 raise IncompleteRead(b''.join(value)) from exc
618
619 def _readinto_chunked(self, b):
620 assert self.chunked != _UNKNOWN
621 total_bytes = 0
622 mvb = memoryview(b)
623 try:
624 while True:
625 chunk_left = self._get_chunk_left()
626 if chunk_left is None:
627 return total_bytes
628
629 if len(mvb) <= chunk_left:
630 n = self._safe_readinto(mvb)
631 self.chunk_left = chunk_left - n
632 return total_bytes + n
633
634 temp_mvb = mvb[:chunk_left]
635 n = self._safe_readinto(temp_mvb)
636 mvb = mvb[n:]
637 total_bytes += n
638 self.chunk_left = 0
639
640 except IncompleteRead:
641 raise IncompleteRead(bytes(b[0:total_bytes]))
642
643 def _safe_read(self, amt):
644 """Read the number of bytes requested.

Callers 1

readintoMethod · 0.95

Calls 3

_get_chunk_leftMethod · 0.95
_safe_readintoMethod · 0.95
IncompleteReadClass · 0.85

Tested by

no test coverage detected