mirror of
https://github.com/bloxstraplabs/bloxstrap.git
synced 2025-04-21 10:01:27 -07:00
reuse httpclient
This commit is contained in:
parent
01a9cff6e1
commit
5fdb341918
@ -66,7 +66,7 @@ namespace Bloxstrap
|
|||||||
"By default, two mod presets are provided for restoring the old death\n" +
|
"By default, two mod presets are provided for restoring the old death\n" +
|
||||||
"sound and the old mouse cursor.\n";
|
"sound and the old mouse cursor.\n";
|
||||||
|
|
||||||
private static readonly HttpClient Client = new();
|
public static readonly HttpClient Client = new();
|
||||||
|
|
||||||
private string? LaunchCommandLine;
|
private string? LaunchCommandLine;
|
||||||
|
|
||||||
|
@ -102,9 +102,7 @@ namespace Bloxstrap.Helpers
|
|||||||
string baseUrl = BuildBaseUrl(channel);
|
string baseUrl = BuildBaseUrl(channel);
|
||||||
string lastDeploy = "";
|
string lastDeploy = "";
|
||||||
|
|
||||||
using (HttpClient client = new())
|
string deployHistory = await Bootstrapper.Client.GetStringAsync($"{baseUrl}/DeployHistory.txt");
|
||||||
{
|
|
||||||
string deployHistory = await client.GetStringAsync($"{baseUrl}/DeployHistory.txt");
|
|
||||||
|
|
||||||
using (StringReader reader = new(deployHistory))
|
using (StringReader reader = new(deployHistory))
|
||||||
{
|
{
|
||||||
@ -116,7 +114,6 @@ namespace Bloxstrap.Helpers
|
|||||||
lastDeploy = line;
|
lastDeploy = line;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (String.IsNullOrEmpty(lastDeploy))
|
if (String.IsNullOrEmpty(lastDeploy))
|
||||||
throw new Exception($"Could not get latest deploy for channel {channel}");
|
throw new Exception($"Could not get latest deploy for channel {channel}");
|
||||||
|
@ -97,16 +97,13 @@ namespace Bloxstrap.Helpers.Integrations
|
|||||||
|
|
||||||
Debug.WriteLine("Installing/Updating rbxfpsunlocker...");
|
Debug.WriteLine("Installing/Updating rbxfpsunlocker...");
|
||||||
|
|
||||||
using (HttpClient client = new())
|
byte[] bytes = await Bootstrapper.Client.GetByteArrayAsync(downloadUrl);
|
||||||
{
|
|
||||||
byte[] bytes = await client.GetByteArrayAsync(downloadUrl);
|
|
||||||
|
|
||||||
using (MemoryStream zipStream = new(bytes))
|
using (MemoryStream zipStream = new(bytes))
|
||||||
{
|
{
|
||||||
ZipArchive zip = new(zipStream);
|
ZipArchive zip = new(zipStream);
|
||||||
zip.ExtractToDirectory(folderLocation, true);
|
zip.ExtractToDirectory(folderLocation, true);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (!File.Exists(settingsLocation))
|
if (!File.Exists(settingsLocation))
|
||||||
{
|
{
|
||||||
|
@ -75,11 +75,8 @@ namespace Bloxstrap.Helpers.RSMM
|
|||||||
string pkgManifestUrl = $"{DeployManager.BaseUrl}/{versionGuid}-rbxPkgManifest.txt";
|
string pkgManifestUrl = $"{DeployManager.BaseUrl}/{versionGuid}-rbxPkgManifest.txt";
|
||||||
string pkgManifestData;
|
string pkgManifestData;
|
||||||
|
|
||||||
using (HttpClient http = new())
|
var getData = Bootstrapper.Client.GetStringAsync(pkgManifestUrl);
|
||||||
{
|
|
||||||
var getData = http.GetStringAsync(pkgManifestUrl);
|
|
||||||
pkgManifestData = await getData.ConfigureAwait(false);
|
pkgManifestData = await getData.ConfigureAwait(false);
|
||||||
}
|
|
||||||
|
|
||||||
return new PackageManifest(pkgManifestData);
|
return new PackageManifest(pkgManifestData);
|
||||||
}
|
}
|
||||||
|
@ -15,13 +15,14 @@ namespace Bloxstrap.Helpers
|
|||||||
|
|
||||||
public static async Task<T?> GetJson<T>(string url)
|
public static async Task<T?> GetJson<T>(string url)
|
||||||
{
|
{
|
||||||
using (HttpClient client = new())
|
var request = await Bootstrapper.Client.SendAsync(new()
|
||||||
{
|
{
|
||||||
client.DefaultRequestHeaders.Add("User-Agent", Program.ProjectRepository);
|
Headers = {
|
||||||
|
{ "User-Agent", Program.ProjectRepository }
|
||||||
string json = await client.GetStringAsync(url);
|
|
||||||
return JsonSerializer.Deserialize<T>(json);
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
var json = await request.Content.ReadAsStringAsync();
|
||||||
|
return JsonSerializer.Deserialize<T>(json);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string MD5File(string filename)
|
public static string MD5File(string filename)
|
||||||
|
Loading…
Reference in New Issue
Block a user