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 <rep...@bugs.python.org>
<http://bugs.python.org/issue16298>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to