diff --git a/Flow.Launcher.Core/ExternalPlugins/PluginsManifest.cs b/Flow.Launcher.Core/ExternalPlugins/PluginsManifest.cs index fb5e3ad87..fab1b3e8f 100644 --- a/Flow.Launcher.Core/ExternalPlugins/PluginsManifest.cs +++ b/Flow.Launcher.Core/ExternalPlugins/PluginsManifest.cs @@ -1,3 +1,4 @@ +using Flow.Launcher.Infrastructure.Http; using Flow.Launcher.Infrastructure.Logger; using System; using System.Collections.Generic; @@ -13,8 +14,6 @@ namespace Flow.Launcher.Core.ExternalPlugins { private const string manifestFileUrl = "https://cdn.jsdelivr.net/gh/Flow-Launcher/Flow.Launcher.PluginsManifest@plugin_api_v2/plugins.json"; - private static HttpClient httpClient = new HttpClient(); - private static readonly SemaphoreSlim manifestUpdateLock = new(1); private static string latestEtag = ""; @@ -30,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 httpClient.SendAsync(request, token).ConfigureAwait(false); + var response = await Http.SendAsync(request, token).ConfigureAwait(false); if (response.StatusCode == HttpStatusCode.OK) { diff --git a/Flow.Launcher.Infrastructure/Http/Http.cs b/Flow.Launcher.Infrastructure/Http/Http.cs index b45b6adcd..c4c8eb5b1 100644 --- a/Flow.Launcher.Infrastructure/Http/Http.cs +++ b/Flow.Launcher.Infrastructure/Http/Http.cs @@ -153,5 +153,13 @@ namespace Flow.Launcher.Infrastructure.Http var response = await client.GetAsync(url, HttpCompletionOption.ResponseHeadersRead, token); return await response.Content.ReadAsStreamAsync(); } + + /// + /// Asynchrously send an HTTP request. + /// + public static async Task SendAsync(HttpRequestMessage request, CancellationToken token = default) + { + return await client.SendAsync(request, token); + } } }