diff --git a/plugins/module_utils/_api/transport/unixconn.py b/plugins/module_utils/_api/transport/unixconn.py index 1d15c5998..3b24fe46a 100644 --- a/plugins/module_utils/_api/transport/unixconn.py +++ b/plugins/module_utils/_api/transport/unixconn.py @@ -13,7 +13,6 @@ import socket from ansible.module_utils.six import PY2 -from ansible.module_utils.six.moves import http_client as httplib from .basehttpadapter import BaseHTTPAdapter from .. import constants @@ -24,17 +23,6 @@ RecentlyUsedContainer = urllib3._collections.RecentlyUsedContainer -class UnixHTTPResponse(httplib.HTTPResponse, object): - def __init__(self, sock, *args, **kwargs): - disable_buffering = kwargs.pop('disable_buffering', False) - if PY2: - # FIXME: We may need to disable buffering on Py3 as well, - # but there's no clear way to do it at the moment. See: - # https://github.com/docker/docker-py/issues/1799 - kwargs['buffering'] = not disable_buffering - super(UnixHTTPResponse, self).__init__(sock, *args, **kwargs) - - class UnixHTTPConnection(urllib3_connection.HTTPConnection, object): def __init__(self, base_url, unix_socket, timeout=60): @@ -58,10 +46,13 @@ def putheader(self, header, *values): self.disable_buffering = True def response_class(self, sock, *args, **kwargs): - if self.disable_buffering: - kwargs['disable_buffering'] = True + if PY2: + # FIXME: We may need to disable buffering on Py3 as well, + # but there's no clear way to do it at the moment. See: + # https://github.com/docker/docker-py/issues/1799 + kwargs['buffering'] = not self.disable_buffering - return UnixHTTPResponse(sock, *args, **kwargs) + return super(UnixHTTPConnection, self).response_class(sock, *args, **kwargs) class UnixHTTPConnectionPool(urllib3.connectionpool.HTTPConnectionPool):