Skip to content

Commit 326049c

Browse files
committed
Fix Unix adapter bug with newer versions of requests
The select_proxy utility in requests errors out when the provided URL doesn't have a hostname, like is the case when using a UNIX socket. Since proxies are an irrelevant notion in the case of UNIX sockets anyway, we simply return the path URL directly. Signed-off-by: Joffrey F <[email protected]>
1 parent fad509b commit 326049c

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

docker/unixconn/unixconn.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,20 @@ def get_connection(self, url, proxies=None):
7373
if pool:
7474
return pool
7575

76-
pool = UnixHTTPConnectionPool(url,
77-
self.socket_path,
78-
self.timeout)
76+
pool = UnixHTTPConnectionPool(
77+
url, self.socket_path, self.timeout
78+
)
7979
self.pools[url] = pool
8080

8181
return pool
8282

83+
def request_url(self, request, proxies):
84+
# The select_proxy utility in requests errors out when the provided URL
85+
# doesn't have a hostname, like is the case when using a UNIX socket.
86+
# Since proxies are an irrelevant notion in the case of UNIX sockets
87+
# anyway, we simply return the path URL directly.
88+
# See also: https://github.com/docker/docker-py/issues/811
89+
return request.path_url
90+
8391
def close(self):
8492
self.pools.clear()

0 commit comments

Comments
 (0)