bugfix: return empty bytes immediately if read length is 0

This commit is contained in:
Alex Stokes 2019-11-07 20:57:55 -08:00
parent 4b01c33d54
commit 2a7b43d853
No known key found for this signature in database
GPG Key ID: 51CE1721B245C086

View File

@ -111,6 +111,9 @@ class SecureSession(BaseSession):
self.high_watermark = len(msg)
async def read(self, n: int = -1) -> bytes:
if n == 0:
return bytes()
data_from_buffer = self._drain(n)
if len(data_from_buffer) > 0:
return data_from_buffer