Skip to content
This repository was archived by the owner on Apr 14, 2022. It is now read-only.

Commit 3ad210b

Browse files
authored
Merge pull request #75 from RatanShreshtha/Fix_test_connect_ipv6_addr
Fix test_connect_ipv6_addr.
2 parents 7f080b5 + 900dbfd commit 3ad210b

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/urllib3/_async/connection.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,16 @@ def _build_tunnel_request(host, port, headers):
210210
Builds a urllib3 Request object that is set up correctly to request a proxy
211211
to establish a TCP tunnel to the remote host.
212212
"""
213-
target = "%s:%d" % (host, port)
213+
214+
try:
215+
socket.inet_pton(socket.AF_INET6, host)
216+
except OSError:
217+
# Not a raw IPv6 address
218+
target = "%s:%d" % (host, port)
219+
else:
220+
# raw IPv6 address
221+
target = "[%s]:%d" % (host, port)
222+
214223
if not isinstance(target, bytes):
215224
target = target.encode('latin1')
216225

test/with_dummyserver/test_socketlevel.py

-1
Original file line numberDiff line numberDiff line change
@@ -1017,7 +1017,6 @@ def handler(listener):
10171017
assert exception.response.status_code == 401
10181018
assert exception.response.headers['x-custom-header'] == 'yougotit'
10191019

1020-
@pytest.mark.xfail
10211020
def test_connect_ipv6_addr(self):
10221021
ipv6_addr = '2001:4998:c:a06::2:4008'
10231022

0 commit comments

Comments
 (0)