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

Commit 900dbfd

Browse files
Update try block to check ipv6 or not
1 parent f99afba commit 900dbfd

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/urllib3/_async/connection.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,9 +213,12 @@ def _build_tunnel_request(host, port, headers):
213213

214214
try:
215215
socket.inet_pton(socket.AF_INET6, host)
216-
target = "[%s]:%d" % (host, port)
217216
except OSError:
217+
# Not a raw IPv6 address
218218
target = "%s:%d" % (host, port)
219+
else:
220+
# raw IPv6 address
221+
target = "[%s]:%d" % (host, port)
219222

220223
if not isinstance(target, bytes):
221224
target = target.encode('latin1')

0 commit comments

Comments
 (0)