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

Method aiter_raw

httpx/_models.py:1037–1063  ·  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

1035 yield line
1036
1037 async def aiter_raw(
1038 self, chunk_size: int | None = None
1039 ) -> typing.AsyncIterator[bytes]:
1040 """
1041 A byte-iterator over the raw response content.
1042 """
1043 if self.is_stream_consumed:
1044 raise StreamConsumed()
1045 if self.is_closed:
1046 raise StreamClosed()
1047 if not isinstance(self.stream, AsyncByteStream):
1048 raise RuntimeError("Attempted to call an async iterator on an sync stream.")
1049
1050 self.is_stream_consumed = True
1051 self._num_bytes_downloaded = 0
1052 chunker = ByteChunker(chunk_size=chunk_size)
1053
1054 with request_context(request=self._request):
1055 async for raw_stream_bytes in self.stream:
1056 self._num_bytes_downloaded += len(raw_stream_bytes)
1057 for chunk in chunker.decode(raw_stream_bytes):
1058 yield chunk
1059
1060 for chunk in chunker.flush():
1061 yield chunk
1062
1063 await self.aclose()
1064
1065 async def aclose(self) -> None:
1066 """

Callers 5

aiter_bytesMethod · 0.95
test_aiter_rawFunction · 0.95
test_aiter_raw_on_syncFunction · 0.95

Calls 7

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

Tested by 4

test_aiter_rawFunction · 0.76
test_aiter_raw_on_syncFunction · 0.76