Skip to content

Commit a5b8b0d

Browse files
committed
add Http.SendAsync, refactor PluginsManifest to use it
1 parent 4d0c57f commit a5b8b0d

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

Flow.Launcher.Core/ExternalPlugins/PluginsManifest.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using Flow.Launcher.Infrastructure.Http;
12
using Flow.Launcher.Infrastructure.Logger;
23
using System;
34
using System.Collections.Generic;
@@ -13,8 +14,6 @@ public static class PluginsManifest
1314
{
1415
private const string manifestFileUrl = "https://cdn.jsdelivr.net/gh/Flow-Launcher/Flow.Launcher.PluginsManifest@plugin_api_v2/plugins.json";
1516

16-
private static HttpClient httpClient = new HttpClient();
17-
1817
private static readonly SemaphoreSlim manifestUpdateLock = new(1);
1918

2019
private static string latestEtag = "";
@@ -30,7 +29,7 @@ public static async Task UpdateManifestAsync(CancellationToken token = default)
3029
var request = new HttpRequestMessage(HttpMethod.Get, manifestFileUrl);
3130
request.Headers.Add("If-None-Match", latestEtag);
3231

33-
var response = await httpClient.SendAsync(request, token).ConfigureAwait(false);
32+
var response = await Http.SendAsync(request, token).ConfigureAwait(false);
3433

3534
if (response.StatusCode == HttpStatusCode.OK)
3635
{

Flow.Launcher.Infrastructure/Http/Http.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,5 +153,13 @@ public static async Task<Stream> GetStreamAsync([NotNull] string url, Cancellati
153153
var response = await client.GetAsync(url, HttpCompletionOption.ResponseHeadersRead, token);
154154
return await response.Content.ReadAsStreamAsync();
155155
}
156+
157+
/// <summary>
158+
/// Asynchrously send an HTTP request.
159+
/// </summary>
160+
public static async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken token = default)
161+
{
162+
return await client.SendAsync(request, token);
163+
}
156164
}
157165
}

0 commit comments

Comments
 (0)