summaryrefslogtreecommitdiff
path: root/src/leap/soledad/common/l2db/remote
diff options
context:
space:
mode:
authorVictor Shyba <victor1984@riseup.net>2017-09-21 18:17:30 -0300
committerVictor Shyba <victor1984@riseup.net>2017-10-05 05:41:40 -0300
commit5d797ddbfe226a2fb6ebff5b4f4184bb41b1b34d (patch)
treebd91ef1b8a4fe9fdc588938810b33cdb4ef7c461 /src/leap/soledad/common/l2db/remote
parentaef72180f681a46534c0d934a62c1376ea2489db (diff)
[refactor] change default dict params
As raised by kali, they can bring some bugs and avoiding it is pretty easy. -- Resolves: #8957
Diffstat (limited to 'src/leap/soledad/common/l2db/remote')
-rw-r--r--src/leap/soledad/common/l2db/remote/http_app.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/leap/soledad/common/l2db/remote/http_app.py b/src/leap/soledad/common/l2db/remote/http_app.py
index a4eddb36..2ec8ac1f 100644
--- a/src/leap/soledad/common/l2db/remote/http_app.py
+++ b/src/leap/soledad/common/l2db/remote/http_app.py
@@ -453,11 +453,12 @@ class HTTPResponder(object):
self.content_type = 'application/json'
self.content = []
- def start_response(self, status, obj_dic=None, headers={}):
+ def start_response(self, status, obj_dic=None, headers=None):
"""start sending response with optional first json object."""
if self._started:
return
self._started = True
+ headers = headers or {}
status_text = httplib.responses[status]
self._write = self._start_response(
'%d %s' % (status, status_text),
@@ -473,13 +474,15 @@ class HTTPResponder(object):
"""finish sending response."""
self.sent_response = True
- def send_response_json(self, status=200, headers={}, **kwargs):
+ def send_response_json(self, status=200, headers=None, **kwargs):
"""send and finish response with json object body from keyword args."""
content = json.dumps(kwargs) + "\r\n"
+ headers = headers or {}
self.send_response_content(content, headers=headers, status=status)
- def send_response_content(self, content, status=200, headers={}):
+ def send_response_content(self, content, status=200, headers=None):
"""send and finish response with content"""
+ headers = headers or {}
headers['content-length'] = str(len(content))
self.start_response(status, headers=headers)
if self._stream_state == 1: