Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make compatible with requests 2.29.0 and urllib3 2.0 #3116

Merged
merged 3 commits into from
May 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 3 additions & 7 deletions docker/transport/npipeconn.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,13 @@
from .. import constants
from .npipesocket import NpipeSocket

import http.client as httplib

try:
import requests.packages.urllib3 as urllib3
except ImportError:
import urllib3
import urllib3
import urllib3.connection

RecentlyUsedContainer = urllib3._collections.RecentlyUsedContainer


class NpipeHTTPConnection(httplib.HTTPConnection):
class NpipeHTTPConnection(urllib3.connection.HTTPConnection):
def __init__(self, npipe_path, timeout=60):
super().__init__(
'localhost', timeout=timeout
Expand Down
10 changes: 3 additions & 7 deletions docker/transport/sshconn.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,8 @@
from docker.transport.basehttpadapter import BaseHTTPAdapter
from .. import constants

import http.client as httplib

try:
import requests.packages.urllib3 as urllib3
except ImportError:
import urllib3
import urllib3
import urllib3.connection

RecentlyUsedContainer = urllib3._collections.RecentlyUsedContainer

Expand Down Expand Up @@ -99,7 +95,7 @@ def close(self):
self.proc.terminate()


class SSHConnection(httplib.HTTPConnection):
class SSHConnection(urllib3.connection.HTTPConnection):
def __init__(self, ssh_transport=None, timeout=60, host=None):
super().__init__(
'localhost', timeout=timeout
Expand Down
5 changes: 1 addition & 4 deletions docker/transport/ssladapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@

from docker.transport.basehttpadapter import BaseHTTPAdapter

try:
import requests.packages.urllib3 as urllib3
except ImportError:
import urllib3
import urllib3


PoolManager = urllib3.poolmanager.PoolManager
Expand Down
15 changes: 3 additions & 12 deletions docker/transport/unixconn.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
import requests.adapters
import socket
import http.client as httplib

from docker.transport.basehttpadapter import BaseHTTPAdapter
from .. import constants

try:
import requests.packages.urllib3 as urllib3
except ImportError:
import urllib3
import urllib3
import urllib3.connection


RecentlyUsedContainer = urllib3._collections.RecentlyUsedContainer


class UnixHTTPConnection(httplib.HTTPConnection):
class UnixHTTPConnection(urllib3.connection.HTTPConnection):
felixfontein marked this conversation as resolved.
Show resolved Hide resolved

def __init__(self, base_url, unix_socket, timeout=60):
super().__init__(
Expand All @@ -30,12 +27,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):
Expand Down
5 changes: 1 addition & 4 deletions docker/types/daemon.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import socket

try:
import requests.packages.urllib3 as urllib3
except ImportError:
import urllib3
import urllib3

from ..errors import DockerException

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/api_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
import docker
import pytest
import requests
import urllib3
from docker.api import APIClient
from docker.constants import DEFAULT_DOCKER_API_VERSION
from requests.packages import urllib3
from unittest import mock

from . import fake_api
Expand Down