UseCookies = false

This commit is contained in:
qhy040404
2024-06-25 22:40:03 +08:00
parent 2f6275e165
commit a6060680f1
4 changed files with 16 additions and 13 deletions

View File

@@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
<metadata>
<id>Snap.Hutao.Deployment.Runtime</id>
<version>1.16.1</version>
<version>1.16.2</version>
<authors>DGP Studio</authors>
<developmentDependency>true</developmentDependency>
<requireLicenseAcceptance>false</requireLicenseAcceptance>

View File

@@ -23,7 +23,7 @@ internal static partial class Invocation
ArgumentException.ThrowIfNullOrEmpty(path);
Console.WriteLine($"""
Snap Hutao Deployment Tool [1.16.1]
Snap Hutao Deployment Tool [1.16.2]
PackagePath: {path}
FamilyName: {name}
------------------------------------------------------------

View File

@@ -34,20 +34,23 @@ internal static class Package
public static async Task DownloadPackageAsync(string packagePath)
{
using (HttpClient httpClient = new())
using (HttpClientHandler handler = new() { UseCookies = false })
{
HttpShardCopyWorkerOptions<DownloadStatus> options = new()
using (HttpClient httpClient = new(handler))
{
HttpClient = httpClient,
SourceUrl = "https://api.snapgenshin.com/patch/hutao/download",
DestinationFilePath = packagePath,
StatusFactory = (bytesRead, totalBytes) => new DownloadStatus(bytesRead, totalBytes),
};
HttpShardCopyWorkerOptions<DownloadStatus> options = new()
{
HttpClient = httpClient,
SourceUrl = "https://api.snapgenshin.com/patch/hutao/download",
DestinationFilePath = packagePath,
StatusFactory = (bytesRead, totalBytes) => new DownloadStatus(bytesRead, totalBytes),
};
using (HttpShardCopyWorker<DownloadStatus> worker = await HttpShardCopyWorker<DownloadStatus>.CreateAsync(options).ConfigureAwait(false))
{
Progress<DownloadStatus> progress = new(ConsoleWriteProgress);
await worker.CopyAsync(progress).ConfigureAwait(false);
using (HttpShardCopyWorker<DownloadStatus> worker = await HttpShardCopyWorker<DownloadStatus>.CreateAsync(options).ConfigureAwait(false))
{
Progress<DownloadStatus> progress = new(ConsoleWriteProgress);
await worker.CopyAsync(progress).ConfigureAwait(false);
}
}
}