summaryrefslogtreecommitdiff
path: root/client/src/leap
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/leap')
-rw-r--r--client/src/leap/soledad/client/http_target/__init__.py8
-rw-r--r--client/src/leap/soledad/client/http_target/api.py22
-rw-r--r--client/src/leap/soledad/client/sqlcipher.py6
-rw-r--r--client/src/leap/soledad/client/sync.py6
4 files changed, 14 insertions, 28 deletions
diff --git a/client/src/leap/soledad/client/http_target/__init__.py b/client/src/leap/soledad/client/http_target/__init__.py
index 5dc87fcb..17b7307c 100644
--- a/client/src/leap/soledad/client/http_target/__init__.py
+++ b/client/src/leap/soledad/client/http_target/__init__.py
@@ -25,8 +25,8 @@ after receiving.
import os
from leap.soledad.common.log import getLogger
-from leap.common.http import HTTPClient
-from twisted.web.client import HTTPConnectionPool
+from leap.common.certs import get_compatible_ssl_context_factory
+from twisted.web.client import Agent
from twisted.internet import reactor
from leap.soledad.client.http_target.send import HTTPDocSender
from leap.soledad.client.http_target.api import SyncTargetAPI
@@ -96,8 +96,8 @@ class SoledadHTTPSyncTarget(SyncTargetAPI, HTTPDocSender, HTTPDocFetcher):
# XXX Increasing timeout of simple requests to avoid chances of hitting
# the duplicated syncing bug. This could be reduced to the 30s default
# after implementing Cancellable Sync. See #7382
- self._http = HTTPClient(cert_file, timeout=90,
- pool=HTTPConnectionPool(reactor))
+ self._http = Agent(reactor,
+ get_compatible_ssl_context_factory(cert_file))
if DO_STATS:
self.sync_exchange_phase = [0]
diff --git a/client/src/leap/soledad/client/http_target/api.py b/client/src/leap/soledad/client/http_target/api.py
index 0e24b37f..1b086a00 100644
--- a/client/src/leap/soledad/client/http_target/api.py
+++ b/client/src/leap/soledad/client/http_target/api.py
@@ -18,11 +18,13 @@ import os
import json
import base64
+from StringIO import StringIO
from uuid import uuid4
from twisted.web.error import Error
from twisted.internet import defer
from twisted.web.http_headers import Headers
+from twisted.web.client import FileBodyProducer
from leap.soledad.client.http_target.support import readBody
from leap.soledad.common.errors import InvalidAuthTokenError
@@ -40,9 +42,6 @@ class SyncTargetAPI(SyncTarget):
Declares public methods and implements u1db.SyncTarget.
"""
- def close(self):
- return self._http.close()
-
@property
def uuid(self):
return self._uuid
@@ -71,17 +70,14 @@ class SyncTargetAPI(SyncTarget):
headers = headers or self._base_header
if content_type:
headers.update({'content-type': [content_type]})
- if not body_producer:
- d = self._http.request(url, method, body, headers, body_reader)
- else:
+ if not body_producer and body:
+ body = FileBodyProducer(StringIO(body))
+ elif body_producer:
# Upload case, check send.py
- # Used to lazy produce body from docs with a custom protocol
- # FIXME: _agent usage to bypass timeout, there is an ongoing
- # discussion on how to properly do it.
- d = self._http._agent.request(
- method, url, headers=Headers(headers),
- bodyProducer=body_producer(body))
- d.addCallback(body_reader)
+ body = body_producer(body)
+ d = self._http.request(
+ method, url, headers=Headers(headers), bodyProducer=body)
+ d.addCallback(body_reader)
d.addErrback(_unauth_to_invalid_token_error)
return d
diff --git a/client/src/leap/soledad/client/sqlcipher.py b/client/src/leap/soledad/client/sqlcipher.py
index bd7d2cc1..f4a3ba6e 100644
--- a/client/src/leap/soledad/client/sqlcipher.py
+++ b/client/src/leap/soledad/client/sqlcipher.py
@@ -533,11 +533,7 @@ class SQLCipherU1DBSync(SQLCipherDatabase):
"""
super(SQLCipherU1DBSync, self).close()
# close all open syncers
- for url in self._syncers.keys():
- _, syncer = self._syncers[url]
- syncer.close()
- del self._syncers[url]
- self.running = False
+ self._syncers = {}
class U1DBSQLiteBackend(sqlite_backend.SQLitePartialExpandDatabase):
diff --git a/client/src/leap/soledad/client/sync.py b/client/src/leap/soledad/client/sync.py
index 9d237d98..272b3f57 100644
--- a/client/src/leap/soledad/client/sync.py
+++ b/client/src/leap/soledad/client/sync.py
@@ -217,12 +217,6 @@ class SoledadSynchronizer(Synchronizer):
# if gapless record current reached generation with target
return self._record_sync_info_with_the_target(info["my_gen"])
- def close(self):
- """
- Close the synchronizer.
- """
- self.sync_target.close()
-
def _record_sync_info_with_the_target(self, start_generation):
"""
Store local replica metadata in server.