diff --git a/src/aiopenapi3/request.py b/src/aiopenapi3/request.py index 62d98cc7..89e34b3b 100644 --- a/src/aiopenapi3/request.py +++ b/src/aiopenapi3/request.py @@ -583,7 +583,10 @@ async def read(self, num_bytes: int) -> bytes: if num_bytes == 0: return b"" - return await anext(self._aiter_bytes) + try: + return await anext(self._aiter_bytes) + except StopAsyncIteration: + return b"" async def aiter_json(response: httpx2.Response) -> AsyncIterator["JSON"]: reader = ReadEventStream(response)