diff options
author | Kali Kaneko <kali@leap.se> | 2017-09-21 16:47:58 +0200 |
---|---|---|
committer | Kali Kaneko <kali@leap.se> | 2017-09-21 18:15:38 +0200 |
commit | e6b39d7037fb8385cd2052713f442416b4c4447a (patch) | |
tree | 3cd1df0a6288253779b32d6203c7ef023300e831 | |
parent | cd6b3ee31a0216c445df599563e180fd91b74ab7 (diff) |
[bug] do not send if-modified-header if file does not exist
just to make the logic clear.
we should probably check that the file is not empty and it has valid
json (sanitized against the spec).
-rw-r--r-- | src/leap/bitmask/bonafide/_http.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/leap/bitmask/bonafide/_http.py b/src/leap/bitmask/bonafide/_http.py index 94d0bcb9..d4a0112c 100644 --- a/src/leap/bitmask/bonafide/_http.py +++ b/src/leap/bitmask/bonafide/_http.py @@ -56,10 +56,11 @@ class Unchanged(Exception): def httpRequest(agent, url, values={}, headers={}, method='POST', token=None, saveto=None): data = '' + mtime = None if values: data = urllib.urlencode(values) headers['Content-Type'] = ['application/x-www-form-urlencoded'] - if saveto is not None: + if saveto is not None and os.path.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. @@ -74,7 +75,7 @@ def httpRequest(agent, url, values={}, headers={}, method='POST', token=None, log.debug("RESPONSE %s %s %s" % (method, response.code, url)) if response.code == 204: d = defer.succeed('') - if response.code == 304: + if saveto and mtime and response.code == 304: log.debug('304 (Not modified): %s' % url) raise Unchanged() else: |