Properly handle EOF.

This commit is contained in:
Eric Snow 2018-02-10 02:08:56 +00:00
parent f98cbb1616
commit f72fb31d1e

View file

@ -16,6 +16,12 @@ def read(stream, look_up=look_up):
except ValueError:
raise RuntimeError('invalid header line: {}'.format(line))
headers[name] = value
else:
# EOF
return None
if not headers:
raise RuntimeError('got message without headers')
size = int(headers['Content-Length'])
body = stream.read(size)