def test_HTTPSConnection(self):
     ctx = create_client_ssl_context()
     ssl = {'ssl_context': ctx}
     h = HTTPSConnection(host=LISTEN_ADDRESS, port=LISTEN_PORT, **ssl)
     h.connect()
     h.putrequest('GET', '/test.html')
     h.endheaders()
     response = h.getresponse()
     self.assertEqual(response.status, 200)
     msg = response.read()
     self.assert_('test_client_node' in msg)
     h.close()
 def test_resume_session(self):
     ctx = create_client_ssl_context()
     ssl = {'ssl_context': ctx}
     sess = None
     sess_key = None
     sess_key_last = None
     for i in xrange(10):
         try:
             hcon = HTTPSConnection(
                 host=LISTEN_ADDRESS, port=LISTEN_PORT, **ssl)
             if sess:
                 hcon.set_session(sess)
             hcon.connect()
             sess = hcon.get_session()
             ctx.add_session(sess)
             hcon.putrequest('GET', '/')
             hcon.endheaders()
             response = hcon.getresponse()
             self.assertEqual(response.status, 200)
             # (status, reason, headers) = hcon.getreply()
             sess_key = get_session_key(sess)
             if sess_key_last:
                 self.assertEqual(sess_key_last, sess_key)
             self.sess_key_last = sess_key
             self.assert_('test_client_node' in response.read())
             hcon.close()
             del hcon
         except Exception as e:
             print e
             raise