libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From je...@apache.org
Subject svn commit: r1054897 - /incubator/libcloud/trunk/libcloud/httplib_ssl.py
Date Tue, 04 Jan 2011 04:56:19 GMT
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,



Mime
View raw message