From cc56933f989275e5dabe35441e224845ef9e7a44 Mon Sep 17 00:00:00 2001 From: Gang Wang Date: Thu, 25 Apr 2024 09:08:29 +0000 Subject: [PATCH 1/2] Correct broken redirects in the case that the response ends without final code 2xx/4xx/5xx --- src/dotnet-install.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/dotnet-install.sh b/src/dotnet-install.sh index 28337df650..42c201af4c 100644 --- a/src/dotnet-install.sh +++ b/src/dotnet-install.sh @@ -1271,6 +1271,12 @@ get_download_link_from_aka_ms() { 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' ) + # 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' ) + fi # All HTTP codes are 301 (Moved Permanently), the redirect link exists. if [[ -z "$broken_redirects" ]]; then From fc9979c309722ed1ce8d2c2693d8fd177359a9d8 Mon Sep 17 00:00:00 2001 From: Gang Wang Date: Fri, 26 Apr 2024 11:05:26 +0000 Subject: [PATCH 2/2] Add test cases for installing dotnet 9 --- tests/Install-Scripts.Test/AkaMsLinksTests.cs | 1 + .../GivenThatIWantToInstallDotnetFromAScript.cs | 3 +++ 2 files changed, 4 insertions(+) diff --git a/tests/Install-Scripts.Test/AkaMsLinksTests.cs b/tests/Install-Scripts.Test/AkaMsLinksTests.cs index 4920e057d5..0906353f44 100644 --- a/tests/Install-Scripts.Test/AkaMsLinksTests.cs +++ b/tests/Install-Scripts.Test/AkaMsLinksTests.cs @@ -41,6 +41,7 @@ public class AkaMsLinksTests : TestBase [InlineData("6.0", "daily", @"https://aka.ms/dotnet/6.0/daily/dotnet-sdk-")] [InlineData("7.0", "daily", @"https://aka.ms/dotnet/7.0/daily/dotnet-sdk-")] + [InlineData("9.0", "preview", @"https://aka.ms/dotnet/9.0/preview/dotnet-sdk-")] public void SDK_IntegrationTest(string channel, string quality, string expectedLink) { string expectedLinkPattern = Regex.Escape(expectedLink); diff --git a/tests/Install-Scripts.Test/GivenThatIWantToInstallDotnetFromAScript.cs b/tests/Install-Scripts.Test/GivenThatIWantToInstallDotnetFromAScript.cs index 67cde90581..1963bdd082 100644 --- a/tests/Install-Scripts.Test/GivenThatIWantToInstallDotnetFromAScript.cs +++ b/tests/Install-Scripts.Test/GivenThatIWantToInstallDotnetFromAScript.cs @@ -38,6 +38,9 @@ public class GivenThatIWantToInstallDotnetFromAScript : IDisposable ("7.0", "7\\.0\\..*", Quality.Ga), ("8.0", "8\\.0\\..*", Quality.None), ("8.0", "8\\.0\\..*", Quality.Ga), + ("9.0", "9\\.0\\..*", Quality.None), + ("9.0", "9\\.0\\..*", Quality.Preview), + ("9.0", "9\\.0\\..*", Quality.Ga), }; ///