Kaydet (Commit) 7625d08c authored tarafından Ben Firshman's avatar Ben Firshman

Stop TLS sockets being closed when attaching

When calling attach_socket, the response is garbage collected,
which triggers a close method on the file object, closing the socket.
This stop the response from being garbage collected until we've
finished with the underlying socket.

Fixes #350
Signed-off-by: 's avatarBen Firshman <ben@firshman.co.uk>
üst a22ee2a9
......@@ -259,9 +259,11 @@ class Client(requests.Session):
def _get_raw_response_socket(self, response):
self._raise_for_status(response)
if six.PY3:
return response.raw._fp.fp.raw._sock
sock = response.raw._fp.fp.raw._sock
else:
return response.raw._fp.fp._sock
sock = response.raw._fp.fp._sock
sock._response = response
return sock
def _stream_helper(self, response):
"""Generator for data coming from a chunked-encoded HTTP response."""
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment