From 1cf34502644353541ef498666e2d2b182d48222e Mon Sep 17 00:00:00 2001 From: qhy040404 Date: Sun, 25 Feb 2024 23:29:39 +0800 Subject: [PATCH] fix static resource download --- .../Core/DependencyInjection/IocHttpClientConfiguration.cs | 1 + src/Snap.Hutao/Snap.Hutao/ViewModel/Guide/DownloadSummary.cs | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Snap.Hutao/Snap.Hutao/Core/DependencyInjection/IocHttpClientConfiguration.cs b/src/Snap.Hutao/Snap.Hutao/Core/DependencyInjection/IocHttpClientConfiguration.cs index feff54e6..de8ef22b 100644 --- a/src/Snap.Hutao/Snap.Hutao/Core/DependencyInjection/IocHttpClientConfiguration.cs +++ b/src/Snap.Hutao/Snap.Hutao/Core/DependencyInjection/IocHttpClientConfiguration.cs @@ -25,6 +25,7 @@ internal static partial class IocHttpClientConfiguration .ConfigurePrimaryHttpMessageHandler((handler, provider) => { HttpClientHandler clientHandler = (HttpClientHandler)handler; + clientHandler.AllowAutoRedirect = true; clientHandler.UseProxy = true; clientHandler.Proxy = provider.GetRequiredService(); }); diff --git a/src/Snap.Hutao/Snap.Hutao/ViewModel/Guide/DownloadSummary.cs b/src/Snap.Hutao/Snap.Hutao/ViewModel/Guide/DownloadSummary.cs index 9942256e..bd98fd8c 100644 --- a/src/Snap.Hutao/Snap.Hutao/ViewModel/Guide/DownloadSummary.cs +++ b/src/Snap.Hutao/Snap.Hutao/ViewModel/Guide/DownloadSummary.cs @@ -76,9 +76,10 @@ internal sealed class DownloadSummary : ObservableObject { HttpResponseMessage response = await httpClient.GetAsync(fileUrl, HttpCompletionOption.ResponseHeadersRead).ConfigureAwait(false); - if (response.Content.Headers.ContentType?.MediaType is not "application/octet-stream") + if (response.Content.Headers.ContentType?.MediaType is not ("application/octet-stream" or "application/zip")) { logger.LogWarning("Download Static Zip failed, Content-Type is {Type}", response.Content.Headers.ContentType); + await taskContext.SwitchToMainThreadAsync(); Description = SH.ViewModelWelcomeDownloadSummaryContentTypeNotMatch; return false; }