Skip to content

Commit 39b9c64

Browse files
committed
Inherit HTTPConnection through urllib3.connection, not httplib
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. This fixes the incompatibility between urllib3 2.0 and requests 1.26+, which was the first version that stopped vendoring urllib3. Reference: docker/docker-py#3113 (comment) Fixes: #70
1 parent 31bdd06 commit 39b9c64

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

requests_unixsocket/adapters.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@
33
from requests.adapters import HTTPAdapter
44
from requests.compat import urlparse, unquote
55

6-
try:
7-
import http.client as httplib
8-
except ImportError:
9-
import httplib
10-
116
try:
127
from requests.packages import urllib3
138
except ImportError:
@@ -16,7 +11,7 @@
1611

1712
# The following was adapted from some code from docker-py
1813
# https://github.com/docker/docker-py/blob/master/docker/transport/unixconn.py
19-
class UnixHTTPConnection(httplib.HTTPConnection, object):
14+
class UnixHTTPConnection(urllib3.connection.HTTPConnection, object):
2015

2116
def __init__(self, unix_socket_url, timeout=60):
2217
"""Create an HTTP connection to a unix domain socket

0 commit comments

Comments
 (0)