Skip to content

Commit

Permalink
replace http+docker special URIs with http:// URLs
Browse files Browse the repository at this point in the history
Fixes docker#1321
be compatable with requests 2.12.2
  • Loading branch information
graingert committed Nov 30, 2016
1 parent 6a16ede commit 82293ce
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions docker/api/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ def __init__(self, base_url=None, version=None,
self._custom_adapter = UnixAdapter(
base_url, timeout, pool_connections=num_pools
)
self.mount('http+docker://', self._custom_adapter)
self.mount('http://unixsocket.docker.com/', self._custom_adapter)
self._unmount('http://', 'https://')
self.base_url = 'http+docker://localunixsocket'
self.base_url = 'http://unixsocket.docker.com'
elif base_url.startswith('npipe://'):
if not IS_WINDOWS_PLATFORM:
raise DockerException(
Expand All @@ -114,8 +114,8 @@ def __init__(self, base_url=None, version=None,
raise DockerException(
'Install pypiwin32 package to enable npipe:// support'
)
self.mount('http+docker://', self._custom_adapter)
self.base_url = 'http+docker://localnpipe'
self.mount('http://npipe.docker.com/', self._custom_adapter)
self.base_url = 'http://npipe.docker.com'
else:
# Use SSLAdapter for the ability to specify SSL version
if isinstance(tls, TLSConfig):
Expand Down Expand Up @@ -254,7 +254,7 @@ def _create_websocket_connection(self, url):

def _get_raw_response_socket(self, response):
self._raise_for_status(response)
if self.base_url == "http+docker://localnpipe":
if self.base_url == "http://npipe.docker.com":
sock = response.raw._fp.fp.raw.sock
elif six.PY3:
sock = response.raw._fp.fp.raw
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 @@ -269,7 +269,7 @@ def test_events_with_filters(self):
)

def _socket_path_for_client_session(self, client):
socket_adapter = client.get_adapter('http+docker://')
socket_adapter = client.get_adapter('http://unixsocket.docker.com')
return socket_adapter.socket_path

def test_url_compatibility_unix(self):
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/fake_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,9 +481,9 @@ def post_fake_network_disconnect():


# Maps real api url to fake response callback
prefix = 'http+docker://localunixsocket'
prefix = 'http://unixsocket.docker.com'
if constants.IS_WINDOWS_PLATFORM:
prefix = 'http+docker://localnpipe'
prefix = 'http://npipe.docker.com'

fake_responses = {
'{0}/version'.format(prefix):
Expand Down

0 comments on commit 82293ce

Please sign in to comment.