From b3e9efc82a04cd0f896b38dbe155a4191db393e5 Mon Sep 17 00:00:00 2001 From: Kali Kaneko Date: Tue, 23 Jan 2018 01:18:46 +0100 Subject: [bug] do not fail if the provider does not allow anonymous vpn Since bonafide was not catching the error 401, an attempt to bootstrap a provider that does not support anonvpn with the new setup was resulting in a json that was containing only an error message. this was producing an error when trying to access the configuration for that provider's EIP section. we now avoid writing a json config file if an error 401 is found, and also catch the exception for a ValueError when the EIP section is not found in the provider's configuration. --- src/leap/bitmask/bonafide/_http.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/leap/bitmask/bonafide') diff --git a/src/leap/bitmask/bonafide/_http.py b/src/leap/bitmask/bonafide/_http.py index a1120ab7..8121a336 100644 --- a/src/leap/bitmask/bonafide/_http.py +++ b/src/leap/bitmask/bonafide/_http.py @@ -51,6 +51,10 @@ class Unchanged(Exception): pass +class Forbidden(Exception): + pass + + # TODO this should be ported to use treq client. def httpRequest(agent, url, values=None, headers=None, @@ -83,6 +87,8 @@ def httpRequest(agent, url, values=None, headers=None, log.debug("RESPONSE %s %s %s" % (method, response.code, url)) if response.code == 204: d = defer.succeed('') + elif response.code == 401: + raise Forbidden() if saveto and mtime and response.code == 304: log.debug('304 (Not modified): %s' % url) raise Unchanged() @@ -104,7 +110,7 @@ def httpRequest(agent, url, values=None, headers=None, return d def passthru(failure): - failure.trap(Unchanged) + failure.trap(Unchanged, Forbidden) d = agent.request(method, url, Headers(headers), StringProducer(data) if data else None) -- cgit v1.2.3