feat: add --header support to web_check()

This commit is contained in:
Martin Wimpress 2024-04-23 06:29:42 +01:00 committed by Martin Wimpress
parent 02b93d9bbe
commit 0f69aeae9a

View File

@ -1298,9 +1298,19 @@ function web_redirect() {
# checks if a URL is reachable
function web_check() {
local HEADERS=()
local URL=""
URL=$(web_redirect "${1}")
curl --silent --location --head --output /dev/null --fail "${URL}"
# Process any headers
while (( "$#" )); do
if [ "${1}" == "--header" ]; then
HEADERS+=("${1}" "${2}")
shift 2
else
shift
fi
done
curl --silent --location --head --output /dev/null --fail "${HEADERS[@]}" "${URL}"
}
function zsync_get() {