public static async Task GetNupkgContentAsync()

in JetBrains.Profiler.SelfApi/src/Impl/NuGet.cs [307:336]


      public static async Task<HttpContent> GetNupkgContentAsync(
        HttpClient http,
        Uri indexUrl,
        string packageId,
        SemanticVersion packageVersion,
        CancellationToken cancellationToken)
      {
        packageId = packageId.ToLowerInvariant();

        var serviceIndex = await GetIndexAsync(http, indexUrl, cancellationToken).ConfigureAwait(false);
        var packageBaseUrl = serviceIndex.GetResourceUrl("PackageBaseAddress/3.0.0");

        var packageIndexUrl = packageBaseUrl.Combine($"{packageId}/index.json");
        var packageIndex = await GetVersionsAsync(http, packageIndexUrl, cancellationToken).ConfigureAwait(false);
        var latestVersion = packageIndex.GetLatestVersion(packageVersion);

        var packageContentUrl = packageBaseUrl
          .Combine($"{packageId}/{latestVersion}/{packageId}.{latestVersion}.nupkg");

        Trace.Info("NuGet.V3.GetNupkgContent: {0}", packageContentUrl);
        var response = await http
          .GetAsync(packageContentUrl, HttpCompletionOption.ResponseHeadersRead, cancellationToken)
          .ConfigureAwait(false);

        response.EnsureSuccessStatusCode();

        response.Content.Headers.Add("Version", latestVersion);

        return response.Content;
      }