From d487d658a429be305dd0d6d35b0f1347f309bab1 Mon Sep 17 00:00:00 2001 From: benoit74 Date: Mon, 23 Oct 2023 14:13:07 +0200 Subject: [PATCH] Use GET instead of HEAD for greater compatibility + close the connection automatically --- zimit.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/zimit.py b/zimit.py index baed799..afb2e03 100755 --- a/zimit.py +++ b/zimit.py @@ -463,10 +463,10 @@ def zimit(args=None): def check_url(url, user_agent, scope=None): url = urllib.parse.urlparse(url) try: - resp = requests.head( + with requests.get( url.geturl(), stream=True, allow_redirects=True, timeout=(12.2, 27), headers={"User-Agent": user_agent} - ) - resp.raise_for_status() + ) as resp: + resp.raise_for_status() except requests.exceptions.RequestException as exc: print(f"failed to connect to {url.geturl()}: {exc}", flush=True) raise SystemExit(1)