Skip to content
Open
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
6 changes: 3 additions & 3 deletions src/dotnet-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1312,13 +1312,13 @@ get_download_link_from_aka_ms() {
say_verbose "Received response: $response"
# Get results of all the redirects.
http_codes=$( echo "$response" | awk '$1 ~ /^HTTP/ {print $2}' )
# They all need to be 301, otherwise some links are broken (except for the last, which is not a redirect but 200 or 404).
broken_redirects=$( echo "$http_codes" | sed '$d' | grep -v '301' )
# Allow intermediate 301 redirects and tolerate proxy-injected 200s
broken_redirects=$( echo "$http_codes" | sed '$d' | grep -vE '^(301|200)$' )
# The response may end without final code 2xx/4xx/5xx somehow, e.g. network restrictions on www.bing.com causes redirecting to bing.com fails with connection refused.
# In this case it should not exclude the last.
last_http_code=$( echo "$http_codes" | tail -n 1 )
if ! [[ $last_http_code =~ ^(2|4|5)[0-9][0-9]$ ]]; then
broken_redirects=$( echo "$http_codes" | grep -v '301' )
broken_redirects=$( echo "$http_codes" | grep -vE '^(301|200)$' )
fi

# All HTTP codes are 301 (Moved Permanently), the redirect link exists.
Expand Down