Eran Rundstein added the comment:
I have attached a patch that includes a (slightly broken) fix and a test case.
Note that there is currently an unresolved issue:
If the user reads the exact amount of bytes the server sent, read() on the
socket will never have a chance to return '' and inform the user about the
connection termination. This will also happen if the user reads more data than
the server is sending. In that case, again, read() will not get called again so
we will never know the socket is gone. One possible way to address this is
perform the actual read() calls in a loop, attempting to read the exact amount
the user specified. If we do this and the user attempts to read more bytes than
the server sent, we will properly detect it. If, however, the user reads the
exact length, then we still have a problem.
I am not sure what would be the correct way of solving this.
Python tracker <rep...@bugs.python.org>
Python-bugs-list mailing list