55
66namespace MaiChartManager . Controllers . Mod ;
77
8- public class MuModService ( ILogger < MuModService > logger )
8+ public class MuModService ( ILogger < MuModService > logger , IHttpClientFactory httpClientFactory )
99{
1010 private const string CosVersionApiUrl = "https://munet-version-config-1251600285.cos.ap-shanghai.myqcloud.com/aquamai.json" ;
1111 private const string CfVersionApiUrl = "https://aquamai-version-config.mumur.net/api/config" ;
@@ -268,12 +268,9 @@ private static IEnumerable<string> BuildDownloadUrls(VersionInfoModel info, Vers
268268 }
269269 }
270270
271- private static async Task < VersionInfoModel [ ] > FetchVersionInfosAsync ( string url , CancellationToken ct )
271+ private async Task < VersionInfoModel [ ] > FetchVersionInfosAsync ( string url , CancellationToken ct )
272272 {
273- using var client = new HttpClient
274- {
275- Timeout = TimeSpan . FromSeconds ( 15 )
276- } ;
273+ using var client = httpClientFactory . CreateClient ( ) ;
277274
278275 var json = await client . GetStringAsync ( url , ct ) ;
279276 var result = JsonSerializer . Deserialize < VersionInfoModel [ ] > ( json , new JsonSerializerOptions
@@ -284,12 +281,9 @@ private static async Task<VersionInfoModel[]> FetchVersionInfosAsync(string url,
284281 return result ?? [ ] ;
285282 }
286283
287- private static async Task < byte [ ] > DownloadFromUrlsAsync ( IReadOnlyList < string > urls , CancellationToken ct )
284+ private async Task < byte [ ] > DownloadFromUrlsAsync ( IReadOnlyList < string > urls , CancellationToken ct )
288285 {
289- using var client = new HttpClient
290- {
291- Timeout = TimeSpan . FromSeconds ( 15 )
292- } ;
286+ using var client = httpClientFactory . CreateClient ( ) ;
293287
294288 Exception ? lastError = null ;
295289 foreach ( var url in urls )
0 commit comments