From fdf9fa81d0e4bd57b5dd9a3492f2bb46bfe11867 Mon Sep 17 00:00:00 2001 From: Quentin Pradet Date: Tue, 2 May 2023 18:11:01 +0400 Subject: [PATCH] Fix urllib3 2.0 compatibility By inheriting from `urllib3.connection.HTTPConnection` (that inherits from `httplib.HTTPConnection` itself), we can adapt to the internal changes in urllib3 2.0 that added a `request()` method that is incompatible with `httplib.HTTPConnection.request`. Signed-off-by: Quentin Pradet --- docker/transport/unixconn.py | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/docker/transport/unixconn.py b/docker/transport/unixconn.py index 1b00762a60..a82468ee16 100644 --- a/docker/transport/unixconn.py +++ b/docker/transport/unixconn.py @@ -1,6 +1,5 @@ import requests.adapters import socket -import http.client as httplib from docker.transport.basehttpadapter import BaseHTTPAdapter from .. import constants @@ -14,7 +13,7 @@ RecentlyUsedContainer = urllib3._collections.RecentlyUsedContainer -class UnixHTTPConnection(httplib.HTTPConnection): +class UnixHTTPConnection(urllib3.connection.HTTPConnection): def __init__(self, base_url, unix_socket, timeout=60): super().__init__( @@ -30,12 +29,6 @@ def connect(self): sock.connect(self.unix_socket) self.sock = sock - def putheader(self, header, *values): - super().putheader(header, *values) - - def response_class(self, sock, *args, **kwargs): - return httplib.HTTPResponse(sock, *args, **kwargs) - class UnixHTTPConnectionPool(urllib3.connectionpool.HTTPConnectionPool): def __init__(self, base_url, socket_path, timeout=60, maxsize=10):