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