[issue16298] httplib.HTTPResponse.read could potentially leave the socket opened forever

Eran Rundstein report at bugs.python.org
Wed Nov 7 02:20:23 CET 2012


Eran Rundstein added the comment:

Hello

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.

----------
keywords: +patch
Added file: http://bugs.python.org/file27913/httplib-no-content-length-close-sock-fix.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue16298>
_______________________________________


More information about the Python-bugs-list mailing list