Modify NetStream to read n bytes

This commit is contained in:
mhchia
2019-08-07 15:23:20 +08:00
committed by Kevin Mai-Husan Chia
parent dbdbcf7440
commit 2485a00e24
4 changed files with 34 additions and 8 deletions

View File

@ -28,12 +28,13 @@ class NetStream(INetStream):
"""
self.protocol_id = protocol_id
async def read(self) -> bytes:
async def read(self, n: int = -1) -> bytes:
"""
read from stream
:return: bytes of input until EOF
reads from stream
:param n: number of bytes to read
:return: bytes of input
"""
return await self.muxed_stream.read()
return await self.muxed_stream.read(n)
async def write(self, data: bytes) -> int:
"""