mirror of
https://github.com/openzim/zimit.git
synced 2025-09-22 11:22:23 -04:00
Use GET instead of HEAD for greater compatibility + close the connection automatically
This commit is contained in:
parent
2a317c91e4
commit
d487d658a4
6
zimit.py
6
zimit.py
@ -463,10 +463,10 @@ def zimit(args=None):
|
|||||||
def check_url(url, user_agent, scope=None):
|
def check_url(url, user_agent, scope=None):
|
||||||
url = urllib.parse.urlparse(url)
|
url = urllib.parse.urlparse(url)
|
||||||
try:
|
try:
|
||||||
resp = requests.head(
|
with requests.get(
|
||||||
url.geturl(), stream=True, allow_redirects=True, timeout=(12.2, 27), headers={"User-Agent": user_agent}
|
url.geturl(), stream=True, allow_redirects=True, timeout=(12.2, 27), headers={"User-Agent": user_agent}
|
||||||
)
|
) as resp:
|
||||||
resp.raise_for_status()
|
resp.raise_for_status()
|
||||||
except requests.exceptions.RequestException as exc:
|
except requests.exceptions.RequestException as exc:
|
||||||
print(f"failed to connect to {url.geturl()}: {exc}", flush=True)
|
print(f"failed to connect to {url.geturl()}: {exc}", flush=True)
|
||||||
raise SystemExit(1)
|
raise SystemExit(1)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user