4 # wrapper around standartd https modules. Properly supports timeouts.
6 class HTTPSConnection(httplib.HTTPSConnection):
7 def __init__(self, host, port=None, key_file=None, cert_file=None,
8 strict=None, timeout = None):
9 httplib.HTTPSConnection.__init__(self, host, port, key_file, cert_file, strict)
10 self.timeout = float(timeout)
13 """Connect to a host on a given (SSL) port."""
14 sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
15 sock.settimeout(self.timeout)
16 sock.connect((self.host, self.port))
17 ssl = socket.ssl(sock, self.key_file, self.cert_file)
18 self.sock = httplib.FakeSocket(sock, ssl)
20 class HTTPS(httplib.HTTPS):
21 def __init__(self, host='', port=None, key_file=None, cert_file=None,
22 strict=None, timeout = None):
23 # urf. compensate for bad input.
26 self._setup(HTTPSConnection(host, port, key_file, cert_file, strict, timeout))
28 # we never actually use these for anything, but we keep them
29 # here for compatibility with post-1.5.2 CVS.
30 self.key_file = key_file
31 self.cert_file = cert_file