summaryrefslogtreecommitdiff
path: root/dns/query.py
diff options
context:
space:
mode:
authorBob Halley <halley@dnspython.org>2020-06-16 07:57:21 -0700
committerBob Halley <halley@dnspython.org>2020-06-16 07:57:21 -0700
commit23627467aa47205617d13fac09f76f8c8b96400b (patch)
tree023daf352d783c7b9d62a55225d7af74e0f66665 /dns/query.py
parent6a3ffe1bdbed8c381d0f4ec86d43909384910cc4 (diff)
downloaddnspython-23627467aa47205617d13fac09f76f8c8b96400b.tar.gz
Use the proper URL syntax for IPv6 address literals.
Diffstat (limited to 'dns/query.py')
-rw-r--r--dns/query.py20
1 files changed, 10 insertions, 10 deletions
diff --git a/dns/query.py b/dns/query.py
index 6d9a10b..17f1bae 100644
--- a/dns/query.py
+++ b/dns/query.py
@@ -302,17 +302,17 @@ def https(q, where, timeout=None, port=443, source=None, source_port=0,
headers = {
"accept": "application/dns-message"
}
- try:
- _ = ipaddress.ip_address(where)
+ if af == dns.inet.AF_INET:
url = 'https://{}:{}{}'.format(where, port, path)
- except ValueError:
- if bootstrap_address is not None:
- split_url = urllib.parse.urlsplit(where)
- headers['Host'] = split_url.hostname
- url = where.replace(split_url.hostname, bootstrap_address)
- transport_adapter = HostHeaderSSLAdapter()
- else:
- url = where
+ elif af == dns.inet.AF_INET6:
+ url = 'https://[{}]:{}{}'.format(where, port, path)
+ elif bootstrap_address is not None:
+ split_url = urllib.parse.urlsplit(where)
+ headers['Host'] = split_url.hostname
+ url = where.replace(split_url.hostname, bootstrap_address)
+ transport_adapter = HostHeaderSSLAdapter()
+ else:
+ url = where
if source is not None:
# set source port and source address
transport_adapter = SourceAddressAdapter(source)