You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by je...@apache.org on 2011/01/04 05:56:19 UTC
svn commit: r1054897 - /incubator/libcloud/trunk/libcloud/httplib_ssl.py
Author: jerry
Date: Tue Jan 4 04:56:19 2011
New Revision: 1054897
URL: http://svn.apache.org/viewvc?rev=1054897&view=rev
Log:
Provide 2.5 fallback for socket.create_connection in httplib_ssl
Modified:
incubator/libcloud/trunk/libcloud/httplib_ssl.py
Modified: incubator/libcloud/trunk/libcloud/httplib_ssl.py
URL: http://svn.apache.org/viewvc/incubator/libcloud/trunk/libcloud/httplib_ssl.py?rev=1054897&r1=1054896&r2=1054897&view=diff
==============================================================================
--- incubator/libcloud/trunk/libcloud/httplib_ssl.py (original)
+++ incubator/libcloud/trunk/libcloud/httplib_ssl.py Tue Jan 4 04:56:19 2011
@@ -86,8 +86,13 @@ class LibcloudHTTPSConnection(httplib.HT
return httplib.HTTPSConnection.connect(self)
# otherwise, create a connection and verify the hostname
- sock = socket.create_connection((self.host, self.port),
- self.timeout)
+ # use socket.create_connection (in 2.6+) if possible
+ if getattr(socket, 'create_connection', None):
+ sock = socket.create_connection((self.host, self.port),
+ self.timeout)
+ else:
+ sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ sock.connect((self.host, self.port))
self.sock = ssl.wrap_socket(sock,
self.key_file,
self.cert_file,