Skip to content

Commit 5c0467a

Browse files
author
FuNK3Y
committed
python-ecosys/aiohttp: Fix partial reads.
Signed-off-by: FuNK3Y <fun__key@hotmail.com>
1 parent f95568d commit 5c0467a

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

python-ecosys/aiohttp/aiohttp/__init__.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff 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)

python-ecosys/aiohttp/aiohttp/aiohttp_ws.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy