From 0ab1783859b3ba0a33f2db861ecb6e494d792a66 Mon Sep 17 00:00:00 2001 From: Ruben Pollan Date: Fri, 29 Sep 2017 14:08:10 +0200 Subject: [bug] _HTTP11ClientFactory constructor has changed in twisted --- src/leap/common/http.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/leap/common/http.py b/src/leap/common/http.py index 1f30903..6550302 100644 --- a/src/leap/common/http.py +++ b/src/leap/common/http.py @@ -109,7 +109,7 @@ class _HTTP11ClientFactory(HTTP11ClientFactory): A timeout-able HTTP 1.1 client protocol factory. """ - def __init__(self, quiescentCallback, timeout): + def __init__(self, quiescentCallback, metadata, timeout): """ :param quiescentCallback: The quiescent callback to be passed to protocol instances, used to return them to @@ -119,7 +119,11 @@ class _HTTP11ClientFactory(HTTP11ClientFactory): protocols created by this factory. :type timeout: float """ - HTTP11ClientFactory.__init__(self, quiescentCallback) + try: + HTTP11ClientFactory.__init__(self, quiescentCallback) + except TypeError: + # Twisted >= 17.9 added an extra param + HTTP11ClientFactory.__init__(self, quiescentCallback, metadata) self._timeout = timeout def buildProtocol(self, _): @@ -144,7 +148,8 @@ class _HTTPConnectionPool(HTTPConnectionPool): def _newConnection(self, key, endpoint): def quiescentCallback(protocol): self._putConnection(key, protocol) - factory = self._factory(quiescentCallback, timeout=self._timeout) + factory = self._factory(quiescentCallback, repr(endpoint), + timeout=self._timeout) return endpoint.connect(factory) -- cgit v1.2.3