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

Antoine Pitrou report at bugs.python.org
Sun Nov 4 15:47:41 CET 2012


Antoine Pitrou added the comment:

> The patch is probably trivial - however I would still like some
> verification.
> Would it be correct to call self.close() when fp.read returns ''? In
> case self.length is not present, I don't see a way around this anyway.
> When it is present, and fp.read returns '', how should we go about
> that? We can either return less data, or raise an exception to
> indicate that the connection terminated prematurely.

It's probably better to return less data. No need to break user programs
when they download from a slightly misbehaved Web site.

The patch should include some kind of unit test, if possible. See
Lib/test/test_httplib.py.

----------

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


More information about the Python-bugs-list mailing list