summaryrefslogtreecommitdiff
path: root/glanceclient/common/https.py
diff options
context:
space:
mode:
Diffstat (limited to 'glanceclient/common/https.py')
-rw-r--r--glanceclient/common/https.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/glanceclient/common/https.py b/glanceclient/common/https.py
index 6416c19..93c6e6a 100644
--- a/glanceclient/common/https.py
+++ b/glanceclient/common/https.py
@@ -265,7 +265,18 @@ class VerifiedHTTPSConnection(HTTPSConnection):
Connect to an SSL port using the OpenSSL library and apply
per-connection parameters.
"""
- sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ result = socket.getaddrinfo(self.host, self.port, 0,
+ socket.SOCK_STREAM)
+ if result:
+ socket_family = result[0][0]
+ if socket_family == socket.AF_INET6:
+ sock = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
+ else:
+ sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ else:
+ # If due to some reason the address lookup fails - we still connect
+ # to IPv4 socket. This retains the older behavior.
+ sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
if self.timeout is not None:
# '0' microseconds
sock.setsockopt(socket.SOL_SOCKET, socket.SO_RCVTIMEO,