MCPcopy
hub / github.com/encode/httpx / iter_raw

Method iter_raw

httpx/_models.py:935–959  ·  view source on GitHub ↗

A byte-iterator over the raw response content.

(self, chunk_size: int | None = None)

Source from the content-addressed store, hash-verified

933 yield line
934
935 def iter_raw(self, chunk_size: int | None = None) -> typing.Iterator[bytes]:
936 """
937 A byte-iterator over the raw response content.
938 """
939 if self.is_stream_consumed:
940 raise StreamConsumed()
941 if self.is_closed:
942 raise StreamClosed()
943 if not isinstance(self.stream, SyncByteStream):
944 raise RuntimeError("Attempted to call a sync iterator on an async stream.")
945
946 self.is_stream_consumed = True
947 self._num_bytes_downloaded = 0
948 chunker = ByteChunker(chunk_size=chunk_size)
949
950 with request_context(request=self._request):
951 for raw_stream_bytes in self.stream:
952 self._num_bytes_downloaded += len(raw_stream_bytes)
953 for chunk in chunker.decode(raw_stream_bytes):
954 yield chunk
955
956 for chunk in chunker.flush():
957 yield chunk
958
959 self.close()
960
961 def close(self) -> None:
962 """

Callers 8

iter_bytesMethod · 0.95
test_iter_rawFunction · 0.95
test_iter_raw_on_asyncFunction · 0.95
test_raw_iteratorFunction · 0.80

Calls 7

decodeMethod · 0.95
flushMethod · 0.95
closeMethod · 0.95
StreamConsumedClass · 0.85
StreamClosedClass · 0.85
ByteChunkerClass · 0.85
request_contextFunction · 0.85