summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/leap/soledad/common/couch/support.py3
-rw-r--r--src/leap/soledad/common/l2db/errors.py8
-rw-r--r--src/leap/soledad/common/l2db/remote/http_app.py9
3 files changed, 12 insertions, 8 deletions
diff --git a/src/leap/soledad/common/couch/support.py b/src/leap/soledad/common/couch/support.py
index bfc4fef6..98000dc9 100644
--- a/src/leap/soledad/common/couch/support.py
+++ b/src/leap/soledad/common/couch/support.py
@@ -49,13 +49,14 @@ class MultipartWriter(object):
self._boundary = boundary
self._build_headers('related', headers)
- def add(self, mimetype, content, headers={}):
+ def add(self, mimetype, content, headers=None):
"""
Add a part to the multipart stream.
"""
self.fileobj.write('--')
self.fileobj.write(self._boundary)
self.fileobj.write(self.CRLF)
+ headers = headers or {}
headers['Content-Type'] = mimetype
self._write_headers(headers)
if content:
diff --git a/src/leap/soledad/common/l2db/errors.py b/src/leap/soledad/common/l2db/errors.py
index b502fc2d..d42860fe 100644
--- a/src/leap/soledad/common/l2db/errors.py
+++ b/src/leap/soledad/common/l2db/errors.py
@@ -143,10 +143,10 @@ class HTTPError(U1DBError):
wire_description = None
- def __init__(self, status, message=None, headers={}):
+ def __init__(self, status, message=None, headers=None):
self.status = status
self.message = message
- self.headers = headers
+ self.headers = headers or {}
def __str__(self):
if not self.message:
@@ -160,8 +160,8 @@ class Unavailable(HTTPError):
wire_description = "unavailable"
- def __init__(self, message=None, headers={}):
- super(Unavailable, self).__init__(503, message, headers)
+ def __init__(self, message=None, headers=None):
+ super(Unavailable, self).__init__(503, message, headers or {})
def __str__(self):
if not self.message:
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: