diff --git a/python-ecosys/aiohttp/aiohttp/__init__.py b/python-ecosys/aiohttp/aiohttp/__init__.py index 8c5493f30..2edc4d1dc 100644 --- a/python-ecosys/aiohttp/aiohttp/__init__.py +++ b/python-ecosys/aiohttp/aiohttp/__init__.py @@ -42,7 +42,13 @@ def _decode(self, data): return data async def read(self, sz=-1): - return self._decode(await self.content.read(sz)) + if sz == -1: + return self._decode(await self.content.read(sz)) + data = bytearray() + while sz > 0: + data.extend(await self.content.read(sz)) + sz -= len(data) + return self._decode(data) async def text(self, encoding="utf-8"): return (await self.read(int(self._get_header("content-length", -1)))).decode(encoding) diff --git a/python-ecosys/aiohttp/aiohttp/aiohttp_ws.py b/python-ecosys/aiohttp/aiohttp/aiohttp_ws.py index 6e0818c92..3b5e92aac 100644 --- a/python-ecosys/aiohttp/aiohttp/aiohttp_ws.py +++ b/python-ecosys/aiohttp/aiohttp/aiohttp_ws.py @@ -203,7 +203,10 @@ async def _read_frame(self): if has_mask: # pragma: no cover mask = await self.reader.read(4) - payload = await self.reader.read(length) + payload = bytearray() + while length > 0: + payload.extend(await self.reader.read(length)) + length -= len(payload) if has_mask: # pragma: no cover payload = bytes(x ^ mask[i % 4] for i, x in enumerate(payload)) return opcode, payload