File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed
python-ecosys/aiohttp/aiohttp Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -42,7 +42,13 @@ def _decode(self, data):
4242 return data
4343
4444 async def read (self , sz = - 1 ):
45- return self ._decode (await self .content .read (sz ))
45+ if sz == - 1 :
46+ return self ._decode (await self .content .read (sz ))
47+ data = bytearray ()
48+ while sz > 0 :
49+ data .extend (await self .content .read (sz ))
50+ sz -= len (data )
51+ return self ._decode (data )
4652
4753 async def text (self , encoding = "utf-8" ):
4854 return (await self .read (int (self ._get_header ("content-length" , - 1 )))).decode (encoding )
Original file line number Diff line number Diff line change @@ -203,7 +203,10 @@ async def _read_frame(self):
203203
204204 if has_mask : # pragma: no cover
205205 mask = await self .reader .read (4 )
206- payload = await self .reader .read (length )
206+ payload = bytearray ()
207+ while length > 0 :
208+ payload .extend (await self .reader .read (length ))
209+ length -= len (payload )
207210 if has_mask : # pragma: no cover
208211 payload = bytes (x ^ mask [i % 4 ] for i , x in enumerate (payload ))
209212 return opcode , payload
@@ -267,3 +270,4 @@ async def __aenter__(self):
267270 async def __aexit__ (self , * args ):
268271 await self .client ._reader .aclose ()
269272 return await asyncio .sleep (0 )
273+
You can’t perform that action at this time.
0 commit comments