diff options
author | Kali Kaneko <kali@leap.se> | 2017-09-21 17:45:25 +0200 |
---|---|---|
committer | Kali Kaneko <kali@leap.se> | 2017-09-21 18:16:27 +0200 |
commit | a271852b1ba74ddbbf2b1c7cc509615ed8cd0664 (patch) | |
tree | 8c11cfe8cc2a8fc55a88002fd350b7d3c19fdda1 /src/leap/bitmask | |
parent | e6b39d7037fb8385cd2052713f442416b4c4447a (diff) |
[bug] fix initialization of default parameter to mutable data structure
whoever wrote this in the first place needs to get introduced to
import-time initialization, even if it was me. one of the nastiest
python gotchas in my opinion :)
Diffstat (limited to 'src/leap/bitmask')
-rw-r--r-- | src/leap/bitmask/bonafide/_http.py | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/leap/bitmask/bonafide/_http.py b/src/leap/bitmask/bonafide/_http.py index d4a0112..a1120ab 100644 --- a/src/leap/bitmask/bonafide/_http.py +++ b/src/leap/bitmask/bonafide/_http.py @@ -53,14 +53,22 @@ class Unchanged(Exception): # TODO this should be ported to use treq client. -def httpRequest(agent, url, values={}, headers={}, method='POST', token=None, - saveto=None): +def httpRequest(agent, url, values=None, headers=None, + method='POST', token=None, saveto=None): + if values is None: + values = {} + if headers is None: + headers = {} + data = '' mtime = None if values: data = urllib.urlencode(values) headers['Content-Type'] = ['application/x-www-form-urlencoded'] - if saveto is not None and os.path.isfile(saveto): + + isfile = os.path.isfile + + if saveto is not None and isfile(saveto): # TODO - I think we need a force parameter, because we might have a # malformed file. Or maybe just remove the file if sanity check does # not pass. |