Skip to content

Commit

Permalink
Inherit HTTPConnection through urllib3.connection, not httplib
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mupuf committed May 30, 2023
1 parent 31bdd06 commit 39b9c64
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions requests_unixsocket/adapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@
from requests.adapters import HTTPAdapter
from requests.compat import urlparse, unquote

try:
import http.client as httplib
except ImportError:
import httplib

try:
from requests.packages import urllib3
except ImportError:
Expand All @@ -16,7 +11,7 @@

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

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

0 comments on commit 39b9c64

Please sign in to comment.