[New-bugs-announce] [issue16298] httplib.HTTPResponse.read could potentially leave the socket opened forever
Eran Rundstein
report at bugs.python.org
Mon Oct 22 13:32:32 CEST 2012
New submission from Eran Rundstein:
When calling HTTPResponse.read() on a response that is:
a. not chunked
b. contains no content-length header
the underlying socket (referenced by self.fp) will never get closed (through self.close())
The offending code is at the bottom of the read() function:
s = self.fp.read(amt)
if self.length is not None:
self.length -= len(s)
if not self.length:
self.close()
return s
As seen, if self.length is None, even when the server closes the connection (causing self.fp.read to return ''), the socket will not get closed.
btw, this may be the cause of Issue15633 (http://bugs.python.org/issue15633)
----------
components: Library (Lib)
messages: 173505
nosy: eranrund
priority: normal
severity: normal
status: open
title: httplib.HTTPResponse.read could potentially leave the socket opened forever
type: behavior
versions: Python 2.7
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue16298>
_______________________________________
More information about the New-bugs-announce
mailing list