From e0a650d9ade2d028b9aaa4f0fb9fb07a371fbdfe Mon Sep 17 00:00:00 2001 From: drebs Date: Mon, 4 Sep 2017 20:30:01 -0300 Subject: [feat] toggle http persistence depending on environment variable --- docs/client.rst | 4 ++++ docs/environment_variables.rst | 6 ++++++ src/leap/soledad/client/_http.py | 4 +++- 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 docs/environment_variables.rst diff --git a/docs/client.rst b/docs/client.rst index 3befd69c..7efabd6f 100644 --- a/docs/client.rst +++ b/docs/client.rst @@ -7,3 +7,7 @@ migrated here in the future. You can also take a look at :ref:`client-side-code-api` and :ref:`client-side-attachments-api` for information on the API. + +.. toctree:: + + environment_variables diff --git a/docs/environment_variables.rst b/docs/environment_variables.rst new file mode 100644 index 00000000..bebc11d6 --- /dev/null +++ b/docs/environment_variables.rst @@ -0,0 +1,6 @@ +Environment Variables +===================== + +Some environment variables affect the behaviour of Soledad Client: + +* ``SOLEDAD_HTTP_PERSIST``: persist HTTP connections. diff --git a/src/leap/soledad/client/_http.py b/src/leap/soledad/client/_http.py index f6e2e28e..1a1260b0 100644 --- a/src/leap/soledad/client/_http.py +++ b/src/leap/soledad/client/_http.py @@ -18,6 +18,7 @@ A twisted-based, TLS-pinned, token-authenticated HTTP client. """ import base64 +import os from twisted.internet import reactor from twisted.web.iweb import IAgent @@ -58,7 +59,8 @@ class PinnedTokenAgent(Agent): self.set_token(token) # pin this agent with the platform TLS certificate factory = getPolicyForHTTPS(cert_file) - pool = HTTPConnectionPool(reactor, persistent=True) + persistent = os.environ.get('SOLEDAD_HTTP_PERSIST', None) + pool = HTTPConnectionPool(reactor, persistent=bool(persistent)) Agent.__init__(self, reactor, contextFactory=factory, pool=pool) def set_token(self, token): -- cgit v1.2.3