From 7680ec18f26ce6bab48c8a57a05e08cba7c6ba5e Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Thu, 22 Sep 2016 01:00:23 -0300 Subject: [feature] stream content in a separate line This allow different paths for raw data and metadata, avoiding unnecessary json parsing. --- client/src/leap/soledad/client/http_target/send_protocol.py | 2 +- client/src/leap/soledad/client/http_target/support.py | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'client/src/leap') diff --git a/client/src/leap/soledad/client/http_target/send_protocol.py b/client/src/leap/soledad/client/http_target/send_protocol.py index c72c6d13..b93a4284 100644 --- a/client/src/leap/soledad/client/http_target/send_protocol.py +++ b/client/src/leap/soledad/client/http_target/send_protocol.py @@ -39,7 +39,7 @@ class DocStreamProducer(object): yield call[0](*call[1:]) while self.producer and not self.stop: if self.pause: - yield self.sleep(0.01) + yield self.sleep(0.001) continue call = self.producer.pop(0) yield call[0](*call[1:]) diff --git a/client/src/leap/soledad/client/http_target/support.py b/client/src/leap/soledad/client/http_target/support.py index fe91c5b1..c066331c 100644 --- a/client/src/leap/soledad/client/http_target/support.py +++ b/client/src/leap/soledad/client/http_target/support.py @@ -169,7 +169,13 @@ class RequestBody(object): :return: length of the entry after JSON dumps :rtype: int """ - entry = json.dumps(entry_dict) + if 'content' in entry_dict: + content = entry_dict['content'] or '' + del entry_dict['content'] + entry = json.dumps(entry_dict) + entry = entry + ',\r\n' + content + else: + entry = json.dumps(entry_dict) self.entries.append(entry) def pop(self, amount=10): -- cgit v1.2.3