@@ -915,12 +915,17 @@ def read(self) -> bytes:
915
915
self ._content = b"" .join (self .iter_bytes ())
916
916
return self ._content
917
917
918
- def iter_bytes (self , chunk_size : int = 512 ) -> typing .Iterator [bytes ]:
918
+ def iter_bytes (
919
+ self , chunk_size : typing .Optional [int ] = 512
920
+ ) -> typing .Iterator [bytes ]:
919
921
"""
920
922
A byte-iterator over the decoded response content.
921
923
This allows us to handle gzip, deflate, and brotli encoded responses.
922
924
"""
923
- yield from drain_by_chunks (self .__iter_bytes (), chunk_size )
925
+ if chunk_size is None :
926
+ yield from self .__iter_bytes ()
927
+ else :
928
+ yield from drain_by_chunks (self .__iter_bytes (), chunk_size )
924
929
925
930
def __iter_bytes (self ) -> typing .Iterator [bytes ]:
926
931
if hasattr (self , "_content" ):
@@ -1001,12 +1006,19 @@ async def aread(self) -> bytes:
1001
1006
self ._content = b"" .join ([part async for part in self .aiter_bytes ()])
1002
1007
return self ._content
1003
1008
1004
- async def aiter_bytes (self , chunk_size : int = 512 ) -> typing .AsyncIterator [bytes ]:
1009
+ async def aiter_bytes (
1010
+ self , chunk_size : typing .Optional [int ] = 512
1011
+ ) -> typing .AsyncIterator [bytes ]:
1005
1012
"""
1006
1013
A byte-iterator over the decoded response content.
1007
1014
This allows us to handle gzip, deflate, and brotli encoded responses.
1008
1015
"""
1009
- async for chunk in async_drain_by_chunks (self .__aiter_bytes (), chunk_size ):
1016
+ if chunk_size is None :
1017
+ aiterator = self .__aiter_bytes ()
1018
+ else :
1019
+ aiterator = async_drain_by_chunks (self .__aiter_bytes (), chunk_size )
1020
+
1021
+ async for chunk in aiterator :
1010
1022
yield chunk
1011
1023
1012
1024
async def __aiter_bytes (self ) -> typing .AsyncIterator [bytes ]:
0 commit comments