Skip to content
This repository was archived by the owner on Jan 13, 2021. It is now read-only.

Commit bf5d204

Browse files
committed
Handle closed sockets as an error.
1 parent 308be18 commit bf5d204

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

hyper/http20/bufsocket.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,11 @@ def read_all_from_buffer():
105105
if ((self._remaining_capacity > self._bytes_in_buffer) and
106106
(should_read)):
107107
count = self._sck.recv_into(self._buffer_view[self._buffer_end:])
108+
109+
# The socket just got closed. We should throw an exception if we
110+
# were asked for more data than we can return.
111+
if not count and amt > self._bytes_in_buffer:
112+
raise ConnectionResetError()
108113
self._bytes_in_buffer += count
109114

110115
# Read out the bytes and update the index.

0 commit comments

Comments
 (0)