[feat] add close method for http agent
[leap_pycommon.git] / src / leap / common / http.py
index d4a214c..8d22f2c 100644 (file)
@@ -80,6 +80,7 @@ class HTTPClient(object):
 
         policy = get_compatible_ssl_context_factory(cert_file)
 
+        self._pool = pool
         self._agent = Agent(
             reactor,
             policy,
@@ -110,6 +111,12 @@ class HTTPClient(object):
         d.addCallback(readBody)
         return d
 
+    def close(self):
+        """
+        Close any cached connections.
+        """
+        self._pool.closeCachedConnections()
+
     class StringBodyProducer(object):
         """
         A producer that writes the body of a request to a consumer.