Commits

coady committed 45dab79

Configurable https client.

Comments (0)

Files changed (3)

         "Return response body from DELETE request."
         return self.call('DELETE', path, params=params)()
 
+if hasattr(httplib, 'HTTPSConnection'):
+    class SResource(Resource, httplib.HTTPSConnection, object):
+        pass
+
 class Pool(collections.deque):
     "Thread-safe resource pool for one host."
+    resource_class = Resource
     def __init__(self, host, limit=0):
         collections.deque.__init__(self, maxlen=limit)
         self.host = host
         try:
             resource = self.popleft()
         except IndexError:
-            resource = Resource(self.host)
+            resource = self.resource_class(self.host)
         resource.request(method, path, body)
         response = yield resource
         try:
 from __future__ import print_function
 import unittest
-import os, sys
+import sys
 import lucene
 
 from .local import TestCase as local
         assert next(stream) is None
         resources.clear()
         self.assertRaises(ValueError, resources.unicast, 'GET', '/')
+        if hasattr(client, 'SResource'):
+            client.Pool.resource_class = client.SResource
+            self.assertRaises(httplib.ssl.SSLError, client.Pool(self.hosts[-1]).call, 'GET', '/')
+        client.Pool.resource_class = client.Resource
     
     def testSharding(self):
         "Sharding of indices across servers."