diff options
author | Matt Martz <matt@sivel.net> | 2019-03-12 18:55:23 +0300 |
---|---|---|
committer | Matt Martz <matt@sivel.net> | 2019-03-12 18:55:23 +0300 |
commit | 9af203652b286ed320bc21ed2f5378317045ec77 (patch) | |
tree | 00136da5ada0d5cac68c8b0183b32f2e43d6f6a9 | |
parent | 2d5a9ef364258621745edafb69c8e592982dac21 (diff) |
Python2.4/2.5 SSL support
-rwxr-xr-x | speedtest.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/speedtest.py b/speedtest.py index be93123..475a96d 100755 --- a/speedtest.py +++ b/speedtest.py @@ -98,6 +98,11 @@ except ImportError: HTTPSConnection = None try: + from httplib import FakeSocket +except ImportError: + FakeSocket = None + +try: from Queue import Queue except ImportError: from queue import Queue @@ -447,6 +452,20 @@ if HTTPSConnection: self.sock.server_hostname = self.host except AttributeError: 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): |