diff --git a/newswire.py b/newswire.py index 748425c4e..54c22ac6b 100644 --- a/newswire.py +++ b/newswire.py @@ -1305,7 +1305,8 @@ def get_rss(base_dir: str, domain: str, session, url: str, result = \ session.get(url, headers=session_headers, params=session_params, - timeout=timeout_sec) + timeout=timeout_sec, + allow_redirects=False) if result: if int(len(result.text) / 1024) < max_feed_size_kb and \ not contains_invalid_chars(result.text): diff --git a/session.py b/session.py index 0f57d03ac..32ffa516c 100644 --- a/session.py +++ b/session.py @@ -71,7 +71,8 @@ def url_exists(session, url: str, timeout_sec: int = 3, try: result = session.get(url, headers=session_headers, params=session_params, - timeout=timeout_sec) + timeout=timeout_sec, + allow_redirects=False) if result: if result.status_code == 200 or \ result.status_code == 304: @@ -91,7 +92,8 @@ def _get_json_request(session, url: str, domain_full: str, session_headers: {}, """ try: result = session.get(url, headers=session_headers, - params=session_params, timeout=timeout_sec) + params=session_params, timeout=timeout_sec, + allow_redirects=False) if result.status_code != 200: if result.status_code == 401: print("WARN: get_json " + url + ' rejected by secure mode') @@ -284,7 +286,8 @@ def get_vcard(xml_format: bool, try: result = session.get(url, headers=session_headers, - params=session_params, timeout=timeout_sec) + params=session_params, timeout=timeout_sec, + allow_redirects=False) if result.status_code != 200: if result.status_code == 401: print("WARN: get_vcard " + url + ' rejected by secure mode') @@ -592,7 +595,8 @@ def download_image(session, base_dir: str, url: str, print('Downloading image url: ' + url) result = session.get(url, headers=session_headers, - params=None) + params=None, + allow_redirects=False) if result.status_code < 200 or \ result.status_code > 202: if debug: @@ -635,7 +639,9 @@ def download_image_any_mime_type(session, url: str, 'Accept': 'image/x-icon, image/png, image/webp, image/jpeg, image/gif' } try: - result = session.get(url, headers=session_headers, timeout=timeout_sec) + result = session.get(url, headers=session_headers, + timeout=timeout_sec, + allow_redirects=False) except requests.exceptions.RequestException as ex: print('EX: download_image_any_mime_type failed1: ' + str(url) + ', ' + str(ex)) diff --git a/webapp_utils.py b/webapp_utils.py index 3c57e913b..aaf7863c4 100644 --- a/webapp_utils.py +++ b/webapp_utils.py @@ -277,7 +277,8 @@ def update_avatar_image_cache(signing_priv_key_pem: str, print('avatar image url: ' + avatar_url) result = session.get(avatar_url, headers=session_headers, - params=None) + params=None, + allow_redirects=False) if result.status_code < 200 or \ result.status_code > 202: if debug: