New submission from Robert Buchholz <[email protected]>:
Calling getresponse() on an httplib.HTTPConnection object returns a response
object. Internally, the self.sock is handed over to the HTTPResponse object
which transforms it into a file-like object. The response object is returned to
the caller. If one calls response.read() later on, no or incomplete content
will be returned because the underlying socket has been closed.
The code path, simplified:
class HTTPConnection:
def getresponse(self):
response = self.response_class(self.sock, ...)
...
if response.will_close:
# this effectively passes the connection to the response
self.close()
def close(self):
if self.sock:
self.sock.close()
...
class HTTPResponse:
def __init__(self, sock, debuglevel=0, strict=0, method=None):
self.fp = sock.makefile('rb', 0)
...
----------
components: Library (Lib)
messages: 98513
nosy: Robert.Buchholz
severity: normal
status: open
title: httplib.HTTPConnection.getresponse closes socket which destroys the
response
versions: Python 2.6
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue7806>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com