From 054f5d93ca2bd9c198cf801718d72bfd58fe646f Mon Sep 17 00:00:00 2001 From: Ella Hathaway Date: Thu, 20 Nov 2025 19:14:29 +0000 Subject: [PATCH] Redirect handling should allow proxy-injected 200 responses --- src/dotnet-install.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/dotnet-install.sh b/src/dotnet-install.sh index eacd79976..68effbd8f 100644 --- a/src/dotnet-install.sh +++ b/src/dotnet-install.sh @@ -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.