Skip to content

Commit 7db3da5

Browse files
authored
Correct broken redirects in the case that the response ends without final code 2xx/4xx/5xx (#464)
* Correct broken redirects in the case that the response ends without final code 2xx/4xx/5xx * Add test cases for installing dotnet 9
1 parent 6d0f3e5 commit 7db3da5

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

src/dotnet-install.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,6 +1271,12 @@ get_download_link_from_aka_ms() {
12711271
http_codes=$( echo "$response" | awk '$1 ~ /^HTTP/ {print $2}' )
12721272
# They all need to be 301, otherwise some links are broken (except for the last, which is not a redirect but 200 or 404).
12731273
broken_redirects=$( echo "$http_codes" | sed '$d' | grep -v '301' )
1274+
# 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.
1275+
# In this case it should not exclude the last.
1276+
last_http_code=$( echo "$http_codes" | tail -n 1 )
1277+
if ! [[ $last_http_code =~ ^(2|4|5)[0-9][0-9]$ ]]; then
1278+
broken_redirects=$( echo "$http_codes" | grep -v '301' )
1279+
fi
12741280
12751281
# All HTTP codes are 301 (Moved Permanently), the redirect link exists.
12761282
if [[ -z "$broken_redirects" ]]; then

tests/Install-Scripts.Test/AkaMsLinksTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public class AkaMsLinksTests : TestBase
4141

4242
[InlineData("6.0", "daily", @"https://aka.ms/dotnet/6.0/daily/dotnet-sdk-")]
4343
[InlineData("7.0", "daily", @"https://aka.ms/dotnet/7.0/daily/dotnet-sdk-")]
44+
[InlineData("9.0", "preview", @"https://aka.ms/dotnet/9.0/preview/dotnet-sdk-")]
4445
public void SDK_IntegrationTest(string channel, string quality, string expectedLink)
4546
{
4647
string expectedLinkPattern = Regex.Escape(expectedLink);

tests/Install-Scripts.Test/GivenThatIWantToInstallDotnetFromAScript.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ public class GivenThatIWantToInstallDotnetFromAScript : IDisposable
3838
("7.0", "7\\.0\\..*", Quality.Ga),
3939
("8.0", "8\\.0\\..*", Quality.None),
4040
("8.0", "8\\.0\\..*", Quality.Ga),
41+
("9.0", "9\\.0\\..*", Quality.None),
42+
("9.0", "9\\.0\\..*", Quality.Preview),
43+
("9.0", "9\\.0\\..*", Quality.Ga),
4144
};
4245

4346
/// <summary>

0 commit comments

Comments
 (0)