[web.controller] improvement: handling http redirect errors

This commit is contained in:
Vinicius Moreira
2021-12-14 12:18:24 -03:00
parent e4370bbe7a
commit 609e47973c
2 changed files with 4 additions and 3 deletions

View File

@@ -12,6 +12,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Web - 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) - 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`) - checking for javascript fixes based on the Electron version (saved on disk as `~/.local/share/bauh/web/fixes/electron_{branch}/{app_name}.js`)
- handling http redirect errors
### Fixes ### Fixes
- UI - UI

View File

@@ -201,13 +201,13 @@ class WebApplicationManager(SoftwareManager):
def serialize_to_disk(self, pkg: SoftwarePackage, icon_bytes: bytes, only_icon: bool): def serialize_to_disk(self, pkg: SoftwarePackage, icon_bytes: bytes, only_icon: bool):
super(WebApplicationManager, self).serialize_to_disk(pkg=pkg, icon_bytes=None, only_icon=False) super(WebApplicationManager, self).serialize_to_disk(pkg=pkg, icon_bytes=None, only_icon=False)
def _request_url(self, url: str) -> Response: def _request_url(self, url: str) -> Optional[Response]:
headers = {'Accept-language': self._get_lang_header(), 'User-Agent': UA_CHROME} headers = {'Accept-language': self._get_lang_header(), 'User-Agent': UA_CHROME}
try: try:
return self.http_client.get(url, headers=headers, ignore_ssl=True, single_call=True, session=False, allow_redirects=True) return self.http_client.get(url, headers=headers, ignore_ssl=True, single_call=True, session=False, allow_redirects=True)
except exceptions.ConnectionError as e: except (exceptions.ConnectionError, requests.exceptions.TooManyRedirects) as e:
self.logger.warning("Could not get {}: {}".format(url, e.__class__.__name__)) self.logger.warning(f"Could not GET {url}. Exception: {e.__class__.__name__}")
def _map_url(self, url: str) -> Tuple["BeautifulSoup", requests.Response]: def _map_url(self, url: str) -> Tuple["BeautifulSoup", requests.Response]:
url_res = self._request_url(url) url_res = self._request_url(url)