From c39a727e3b6264781e7eae1f12afa4e693cb87cc Mon Sep 17 00:00:00 2001 From: Hongtao Zhang Date: Thu, 13 Oct 2022 11:36:43 -0500 Subject: [PATCH] Revert back some unnecessary change --- Flow.Launcher.Core/ExternalPlugins/PluginsManifest.cs | 4 ++-- Flow.Launcher.Core/Updater.cs | 11 +++++------ Flow.Launcher.Infrastructure/Http/Http.cs | 4 ++-- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/Flow.Launcher.Core/ExternalPlugins/PluginsManifest.cs b/Flow.Launcher.Core/ExternalPlugins/PluginsManifest.cs index fab1b3e8f..b735e95e7 100644 --- a/Flow.Launcher.Core/ExternalPlugins/PluginsManifest.cs +++ b/Flow.Launcher.Core/ExternalPlugins/PluginsManifest.cs @@ -29,7 +29,7 @@ namespace Flow.Launcher.Core.ExternalPlugins var request = new HttpRequestMessage(HttpMethod.Get, manifestFileUrl); request.Headers.Add("If-None-Match", latestEtag); - var response = await Http.SendAsync(request, token).ConfigureAwait(false); + using var response = await Http.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, token).ConfigureAwait(false); if (response.StatusCode == HttpStatusCode.OK) { @@ -56,4 +56,4 @@ namespace Flow.Launcher.Core.ExternalPlugins } } } -} \ No newline at end of file +} diff --git a/Flow.Launcher.Core/Updater.cs b/Flow.Launcher.Core/Updater.cs index 96dce8ed9..44c47cf28 100644 --- a/Flow.Launcher.Core/Updater.cs +++ b/Flow.Launcher.Core/Updater.cs @@ -79,7 +79,7 @@ namespace Flow.Launcher.Core await updateManager.CreateUninstallerRegistryEntry().ConfigureAwait(false); } - var newVersionTips = NewVersinoTips(newReleaseVersion.ToString()); + var newVersionTips = NewVersionTips(newReleaseVersion.ToString()); Log.Info($"|Updater.UpdateApp|Update success:{newVersionTips}"); @@ -120,8 +120,7 @@ namespace Flow.Launcher.Core var uri = new Uri(repository); var api = $"https://api.github.com/repos{uri.AbsolutePath}/releases"; - using var response = await Http.GetResponseAsync(api, HttpCompletionOption.ResponseHeadersRead).ConfigureAwait(false); - await using var jsonStream = await response.Content.ReadAsStreamAsync(); + await using var jsonStream = await Http.GetStreamAsync(api).ConfigureAwait(false); var releases = await System.Text.Json.JsonSerializer.DeserializeAsync>(jsonStream).ConfigureAwait(false); var latest = releases.Where(r => !r.Prerelease).OrderByDescending(r => r.PublishedAt).First(); @@ -138,10 +137,10 @@ namespace Flow.Launcher.Core return manager; } - public string NewVersinoTips(string version) + public string NewVersionTips(string version) { - var translater = InternationalizationManager.Instance; - var tips = string.Format(translater.GetTranslation("newVersionTips"), version); + var translator = InternationalizationManager.Instance; + var tips = string.Format(translator.GetTranslation("newVersionTips"), version); return tips; } diff --git a/Flow.Launcher.Infrastructure/Http/Http.cs b/Flow.Launcher.Infrastructure/Http/Http.cs index 0be9af5a4..e5be0701f 100644 --- a/Flow.Launcher.Infrastructure/Http/Http.cs +++ b/Flow.Launcher.Infrastructure/Http/Http.cs @@ -178,9 +178,9 @@ namespace Flow.Launcher.Infrastructure.Http /// /// Asynchrously send an HTTP request. /// - public static async Task SendAsync(HttpRequestMessage request, CancellationToken token = default) + public static async Task SendAsync(HttpRequestMessage request, HttpCompletionOption completionOption = HttpCompletionOption.ResponseContentRead, CancellationToken token = default) { - return await client.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, token); + return await client.SendAsync(request, completionOption, token); } } }