@@ -121,20 +121,21 @@ nvm_download() {
121
121
if nvm_curl_use_compression; then
122
122
CURL_COMPRESSED_FLAG=" --compressed"
123
123
fi
124
- curl --fail ${CURL_COMPRESSED_FLAG:- } -q " $@ "
124
+ # shellcheck disable=SC1083
125
+ curl --fail ${CURL_COMPRESSED_FLAG:- } -q -w %{http_code} " $@ "
125
126
elif nvm_has " wget" ; then
126
127
# Emulate curl with wget
127
128
ARGS=$( nvm_echo " $@ " | command sed -e ' s/--progress-bar /--progress=bar /' \
128
- -e ' s/--compressed //' \
129
- -e ' s/--fail //' \
130
- -e ' s/-L //' \
131
- -e ' s/-I /--server-response /' \
132
- -e ' s/-s /-q /' \
133
- -e ' s/-sS /-nv /' \
134
- -e ' s/-o /-O /' \
135
- -e ' s/-C - /-c /' )
129
+ -e ' s/--compressed //' \
130
+ -e ' s/--fail //' \
131
+ -e ' s/-L //' \
132
+ -e ' s/-I /--server-response /' \
133
+ -e ' s/-s /-q /' \
134
+ -e ' s/-sS /-nv /' \
135
+ -e ' s/-o /-O /' \
136
+ -e ' s/-C - /-c /' )
136
137
# shellcheck disable=SC2086
137
- eval wget $ARGS
138
+ eval wget -S $ARGS 2>&1 | grep ' ^ HTTP/ ' | awk ' {print $2} '
138
139
fi
139
140
}
140
141
@@ -2298,12 +2299,17 @@ nvm_download_artifact() {
2298
2299
nvm_err " Removing the broken local cache..."
2299
2300
command rm -rf " ${TARBALL} "
2300
2301
fi
2302
+
2301
2303
nvm_err " Downloading ${TARBALL_URL} ..."
2302
- nvm_download -L -C - " ${PROGRESS_BAR} " " ${TARBALL_URL} " -o " ${TARBALL} " || (
2304
+ download_result=$( nvm_download -L -C - " ${PROGRESS_BAR} " " ${TARBALL_URL} " -o " ${TARBALL} " )
2305
+ if [ " ${NVM_DEBUG-} " = 1 ]; then
2306
+ nvm_err " Download HTTP Status ${download_result} "
2307
+ fi
2308
+ if [ " ${download_result} " != ' 200' ]; then
2303
2309
command rm -rf " ${TARBALL} " " ${tmpdir} "
2304
2310
nvm_err " Binary download from ${TARBALL_URL} failed, trying source."
2305
2311
return 4
2306
- )
2312
+ fi
2307
2313
2308
2314
if nvm_grep ' 404 Not Found' " ${TARBALL} " > /dev/null; then
2309
2315
command rm -rf " ${TARBALL} " " ${tmpdir} "
0 commit comments