refactor: Use .NET HTTP client in favor of the custom client

This commit is contained in:
2025-06-21 02:22:50 +08:00
parent e0362bbb58
commit 38421b7a53
15 changed files with 8 additions and 598 deletions

View File

@@ -1,5 +1,4 @@
using Cryville.Common;
using Cryville.Common.Network.Http11;
using Cryville.Common.Unity;
using Cryville.Crtr.UI;
using Newtonsoft.Json;
@@ -7,6 +6,7 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net.Http;
#if UNITY_STANDALONE_WIN && !UNITY_EDITOR
using System.Runtime.InteropServices;
#endif
@@ -46,10 +46,10 @@ namespace Cryville.Crtr.Network {
}
}
void CheckVersion() {
using (var client = new Https11Client(BaseUri)) {
using (var client = new HttpClient()) {
client.Connect();
using var response = client.Request("GET", new Uri(BaseUri, "versions"));
var data = Encoding.UTF8.GetString(response.MessageBody.ReadToEnd());
using var response = client.GetAsync(new Uri(BaseUri, "versions")).Result;
var data = response.Content.ReadAsStringAsync().Result;
_versions = JsonConvert.DeserializeObject<List<VersionInfo>>(data, Game.GlobalJsonSerializerSettings);
}
var availableVersions = _versions.Where(v => v.platforms.ContainsKey(PlatformConfig.Name)).ToArray();
@@ -131,12 +131,12 @@ namespace Cryville.Crtr.Network {
}
void Download(VersionResourceInfo diff, string path) {
var uri = new Uri(diff.url);
using var client = new Https11Client(uri);
using var client = new HttpClient();
client.Connect();
using var response = client.Request("GET", uri);
var data = response.MessageBody.ReadToEnd();
using var response = client.GetAsync(uri).Result;
using var stream = response.Content.ReadAsStreamAsync().Result;
using var file = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.None);
file.Write(data);
stream.CopyTo(file);
}
void ExecuteUpdate(List<string> diffPaths) {
#if UNITY_EDITOR