Skip to content

Commit cdf68aa

Browse files
committed
fix: improve HTTP download error handling for wget and curl
- Updated `http_download_curl` to log HTTP errors using `log_err` instead of `log_debug`. - Modified `http_download_wget` to check HTTP status codes, mirroring curl's behavior. - Return exit status 1 for non-200 responses in `http_download_wget`. - Standardized error logging across both download functions.
1 parent 2691aac commit cdf68aa

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

install.sh

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ http_download_curl() {
301301
code=$(curl -w '%{http_code}' -sL -H "$header" -o "$local_file" "$source_url")
302302
fi
303303
if [ "$code" != "200" ]; then
304-
log_debug "http_download_curl received HTTP status $code"
304+
log_err "http_download_curl received HTTP status $code"
305305
return 1
306306
fi
307307
return 0
@@ -311,10 +311,15 @@ http_download_wget() {
311311
source_url=$2
312312
header=$3
313313
if [ -z "$header" ]; then
314-
wget -q -O "$local_file" "$source_url"
314+
code=$(wget --server-response --quiet -O "$local_file" "$source_url" 2>&1 | awk '/^ HTTP/{print $2}' | tail -n1)
315315
else
316-
wget -q --header "$header" -O "$local_file" "$source_url"
316+
code=$(wget --server-response --quiet --header "$header" -O "$local_file" "$source_url" 2>&1 | awk '/^ HTTP/{print $2}' | tail -n1)
317317
fi
318+
if [ "$code" != "200" ]; then
319+
log_err "http_download_wget received HTTP status $code"
320+
return 1
321+
fi
322+
return 0
318323
}
319324
http_download() {
320325
log_debug "http_download $2"

0 commit comments

Comments
 (0)