From cdf68aa1be9495235e2e54e7e28b8ec9d56c93be Mon Sep 17 00:00:00 2001 From: Taylor Jasko Date: Mon, 28 Jul 2025 17:59:09 -0500 Subject: [PATCH 1/2] 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. --- install.sh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/install.sh b/install.sh index 4076fc35aed0..018a650127b8 100755 --- a/install.sh +++ b/install.sh @@ -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 @@ -311,10 +311,15 @@ http_download_wget() { source_url=$2 header=$3 if [ -z "$header" ]; then - wget -q -O "$local_file" "$source_url" + code=$(wget --server-response --quiet -O "$local_file" "$source_url" 2>&1 | awk '/^ HTTP/{print $2}' | tail -n1) else - wget -q --header "$header" -O "$local_file" "$source_url" + code=$(wget --server-response --quiet --header "$header" -O "$local_file" "$source_url" 2>&1 | awk '/^ HTTP/{print $2}' | tail -n1) fi + 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" From a8f43c243e5e8169d08f4c145ac74317c765e7f2 Mon Sep 17 00:00:00 2001 From: Taylor Jasko Date: Mon, 28 Jul 2025 21:13:23 -0500 Subject: [PATCH 2/2] fix: updating `http_download_wget()` to handle more failure scenarios --- install.sh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index 018a650127b8..7a59cb4ce865 100755 --- a/install.sh +++ b/install.sh @@ -310,11 +310,19 @@ http_download_wget() { local_file=$1 source_url=$2 header=$3 + local wget_output + local code if [ -z "$header" ]; then - code=$(wget --server-response --quiet -O "$local_file" "$source_url" 2>&1 | awk '/^ HTTP/{print $2}' | tail -n1) + wget_output=$(wget --server-response --quiet -O "$local_file" "$source_url" 2>&1) else - code=$(wget --server-response --quiet --header "$header" -O "$local_file" "$source_url" 2>&1 | awk '/^ HTTP/{print $2}' | tail -n1) + 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