mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
add Http.SendAsync, refactor PluginsManifest to use it
This commit is contained in:
parent
4d0c57f52f
commit
a5b8b0dcb2
2 changed files with 10 additions and 3 deletions
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -153,5 +153,13 @@ namespace Flow.Launcher.Infrastructure.Http
|
|||
var response = await client.GetAsync(url, HttpCompletionOption.ResponseHeadersRead, token);
|
||||
return await response.Content.ReadAsStreamAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Asynchrously send an HTTP request.
|
||||
/// </summary>
|
||||
public static async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken token = default)
|
||||
{
|
||||
return await client.SendAsync(request, token);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue