When we see an incomplete read with 0 bytes, it's a disconnect

Partially fixes mitmproxy/mitmproxy:#593
This commit is contained in:
Aldo Cortesi 2015-05-31 17:18:55 +12:00
parent 73376e605a
commit f7bd690e3a

View File

@ -225,6 +225,9 @@ class Reader(_FileLike):
"""
result = self.read(length)
if length != -1 and len(result) != length:
if not result:
raise NetLibDisconnect()
else:
raise NetLibIncomplete(
"Expected %s bytes, got %s" % (length, len(result))
)