Python2.4/2.5 SSL support

This commit is contained in:
Matt Martz 2019-03-12 10:55:23 -05:00
parent 2d5a9ef364
commit 9af203652b
1 changed files with 19 additions and 0 deletions

View File

@ -97,6 +97,11 @@ except ImportError:
except ImportError: except ImportError:
HTTPSConnection = None HTTPSConnection = None
try:
from httplib import FakeSocket
except ImportError:
FakeSocket = None
try: try:
from Queue import Queue from Queue import Queue
except ImportError: except ImportError:
@ -447,6 +452,20 @@ if HTTPSConnection:
self.sock.server_hostname = self.host self.sock.server_hostname = self.host
except AttributeError: except AttributeError:
pass pass
elif FakeSocket:
# Python 2.4/2.5 support
try:
self.sock = FakeSocket(self.sock, socket.ssl(self.sock))
except AttributeError:
raise SpeedtestException(
'This version of Python does not support HTTPS/SSL '
'functionality'
)
else:
raise SpeedtestException(
'This version of Python does not support HTTPS/SSL '
'functionality'
)
def _build_connection(connection, source_address, timeout, context=None): def _build_connection(connection, source_address, timeout, context=None):