diff --git a/CHANGELOG.md b/CHANGELOG.md index 9cb03a65..2876ffd6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [0.9.24] ### Improvements +- General + - handling http redirect errors + - Web - able to specify a custom User-Agent when installing apps that demand specific settings to work properly on Electron 13.X (e.g: WhatsApp Web) - checking for javascript fixes based on the Electron version (saved on disk as `~/.local/share/bauh/web/fixes/electron_{branch}/{app_name}.js`) diff --git a/bauh/api/http.py b/bauh/api/http.py index 20b9a84d..4fc9ba68 100644 --- a/bauh/api/http.py +++ b/bauh/api/http.py @@ -52,7 +52,10 @@ class HttpClient: except Exception as e: if isinstance(e, requests.exceptions.ConnectionError): self.logger.error('Internet seems to be off') - raise + raise e + elif isinstance(e, requests.exceptions.TooManyRedirects): + self.logger.warning(f"Too many redirects for GET -> {url}") + raise e self.logger.error("Could not retrieve data from '{}'".format(url)) traceback.print_exc() @@ -100,9 +103,14 @@ class HttpClient: def exists(self, url: str, session: bool = True, timeout: int = 5) -> bool: params = {'url': url, 'allow_redirects': True, 'verify': False, 'timeout': timeout} - if session: - res = self.session.head(**params) - else: - res = self.session.get(**params) + + try: + if session: + res = self.session.head(**params) + else: + res = self.session.get(**params) + except requests.exceptions.TooManyRedirects: + self.logger.warning(f"{url} seems to exist, but too many redirects have happened") + return True return res.status_code in (200, 403)