From 38ddde3299cc15d1d6da6ebe5a462c82dbdfd628 Mon Sep 17 00:00:00 2001 From: Jan Provaznik Date: Fri, 7 Feb 2025 15:29:32 +0100 Subject: [PATCH] remove backup parsing --- src/dotnet-install.ps1 | 31 ---------------------- src/dotnet-install.sh | 60 ------------------------------------------ 2 files changed, 91 deletions(-) diff --git a/src/dotnet-install.ps1 b/src/dotnet-install.ps1 index f86c2fbad..6b06fb9ad 100644 --- a/src/dotnet-install.ps1 +++ b/src/dotnet-install.ps1 @@ -992,32 +992,6 @@ function PrintDryRunOutput($Invocation, $DownloadLinks) { } } -# grab the 'stem' of the redirect and check it against all of our configured feeds, -# if it matches, we can be sure that the redirect is valid and we should use it for -# subsequent processing -function Sanitize-RedirectUrl([string]$url) { - $urlSegments = ([System.Uri]$url).Segments; - $urlStem = $urlSegments[2..($urlSegments.Length - 1)] -join ""; - Write-Verbose "Checking configured feeds for the asset at $urlStem" - foreach ($prospectiveFeed in $feeds) { - $trialUrl = "$prospectiveFeed/$urlStem"; - Write-Verbose "Checking $trialUrl" - try { - $trialResponse = Invoke-WebRequest -Uri $trialUrl -Method HEAD - if ($trialResponse.StatusCode -eq 200) { - Write-Verbose "Found a match at $trialUrl" - return $trialUrl; - } - else { - Write-Verbose "No match at $trialUrl" - } - } - catch { - Write-Verbose "Failed to check $trialUrl" - } - } -} - function Get-AkaMSDownloadLink([string]$Channel, [string]$Quality, [bool]$Internal, [string]$Product, [string]$Architecture) { Say-Invocation $MyInvocation @@ -1076,11 +1050,6 @@ function Get-AkaMSDownloadLink([string]$Channel, [string]$Quality, [bool]$Intern } elseif ((($Response.StatusCode -lt 300) -or ($Response.StatusCode -ge 400)) -and (-not [string]::IsNullOrEmpty($akaMsDownloadLink))) { # Redirections have ended. - $actualRedirectUrl = Sanitize-RedirectUrl $akaMsDownloadLink - if ($null -ne $actualRedirectUrl) { - $akaMsDownloadLink = $actualRedirectUrl - } - return $akaMsDownloadLink } diff --git a/src/dotnet-install.sh b/src/dotnet-install.sh index 8330fa904..63ae00958 100644 --- a/src/dotnet-install.sh +++ b/src/dotnet-install.sh @@ -1272,61 +1272,6 @@ downloadwget() { return 0 } -extract_stem() { - local url="$1" - # extract the protocol - proto="$(echo $1 | grep :// | sed -e's,^\(.*://\).*,\1,g')" - # remove the protocol - url="${1/$proto/}" - # extract the path (if any) - since we know all of our feeds have a first path segment, we can skip the first one. otherwise we'd use -f2- to get the full path - full_path="$(echo $url | grep / | cut -d/ -f2-)" - path="$(echo $full_path | cut -d/ -f2-)" - echo $path -} - -check_url_exists() { - eval $invocation - local url="$1" - - local code="" - if machine_has "curl" - then - code=$(curl --head -o /dev/null -w "%{http_code}" -s --fail "$url"); - elif machine_has "wget" - then - # get the http response, grab the status code - server_response=$(wget -qO- --method=HEAD --server-response "$url" 2>&1) - code=$(echo "$server_response" | grep "HTTP/" | awk '{print $2}') - fi - if [ $code = "200" ]; then - return 0 - else - return 1 - fi -} - -sanitize_redirect_url() { - eval $invocation - - local url_stem - url_stem=$(extract_stem "$1") - say_verbose "Checking configured feeds for the asset at ${yellow:-}$url_stem${normal:-}" - - for feed in "${feeds[@]}" - do - local trial_url="$feed/$url_stem" - say_verbose "Checking ${yellow:-}$trial_url${normal:-}" - if check_url_exists "$trial_url"; then - say_verbose "Found a match at ${yellow:-}$trial_url${normal:-}" - echo "$trial_url" - return 0 - else - say_verbose "No match at ${yellow:-}$trial_url${normal:-}" - fi - done - return 1 -} - get_download_link_from_aka_ms() { eval $invocation @@ -1379,11 +1324,6 @@ get_download_link_from_aka_ms() { return 1 fi - sanitized_redirect_url=$(sanitize_redirect_url "$aka_ms_download_link") - if [[ -n "$sanitized_redirect_url" ]]; then - aka_ms_download_link="$sanitized_redirect_url" - fi - say_verbose "The redirect location retrieved: '$aka_ms_download_link'." return 0 else