From 4e7e6cb3de63efa7baa89a564082c2f7e26f480b Mon Sep 17 00:00:00 2001 From: jessevz Date: Tue, 17 Mar 2026 19:16:42 +0100 Subject: [PATCH 1/2] Support redirect for head request for downloads --- htpclient/download.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htpclient/download.py b/htpclient/download.py index 36bbfd3..328b916 100644 --- a/htpclient/download.py +++ b/htpclient/download.py @@ -17,7 +17,7 @@ def download(url, output, no_header=False): # Check header if not no_header: - head = session.head(url) + head = session.head(url, allow_redirects=True) # not sure if we only should allow 200/301/302, but then it's present for sure if head.status_code not in [200, 301, 302]: logging.error("File download header reported wrong status code: " + str(head.status_code)) From 413b3f62d704dcc0a912a2bb395a0cdddb6b55f0 Mon Sep 17 00:00:00 2001 From: jessevz Date: Wed, 18 Mar 2026 09:50:47 +0100 Subject: [PATCH 2/2] Simplified the status code check of the head request --- htpclient/download.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htpclient/download.py b/htpclient/download.py index 328b916..3834dda 100644 --- a/htpclient/download.py +++ b/htpclient/download.py @@ -18,8 +18,7 @@ def download(url, output, no_header=False): # Check header if not no_header: head = session.head(url, allow_redirects=True) - # not sure if we only should allow 200/301/302, but then it's present for sure - if head.status_code not in [200, 301, 302]: + if not head.ok: logging.error("File download header reported wrong status code: " + str(head.status_code)) return False