Skip to content

dev: improve HTTP download error handling for wget and curl #5962

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 9, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ http_download_curl() {
code=$(curl -w '%{http_code}' -sL -H "$header" -o "$local_file" "$source_url")
fi
if [ "$code" != "200" ]; then
log_debug "http_download_curl received HTTP status $code"
log_err "http_download_curl received HTTP status $code"
return 1
fi
return 0
Expand All @@ -310,11 +310,24 @@ http_download_wget() {
local_file=$1
source_url=$2
header=$3
local wget_output
local code
if [ -z "$header" ]; then
wget -q -O "$local_file" "$source_url"
wget_output=$(wget --server-response --quiet -O "$local_file" "$source_url" 2>&1)
else
wget -q --header "$header" -O "$local_file" "$source_url"
wget_output=$(wget --server-response --quiet --header "$header" -O "$local_file" "$source_url" 2>&1)
fi
local wget_exit=$?
if [ $wget_exit -ne 0 ]; then
log_err "http_download_wget failed: wget exited with status $wget_exit"
return 1
fi
code=$(echo "$wget_output" | awk '/^ HTTP/{print $2}' | tail -n1)
if [ "$code" != "200" ]; then
log_err "http_download_wget received HTTP status $code"
return 1
fi
return 0
}
http_download() {
log_debug "http_download $2"
Expand Down
Loading