Revert "Merge pull request #45 from bluepilledgreat/reuse-httpclient"

This reverts commit c6410eb407, reversing
changes made to 5b94b2741a.
This commit is contained in:
pizzaboxer 2022-11-14 17:40:00 +00:00
parent c6410eb407
commit 7295a8eec7
5 changed files with 30 additions and 24 deletions

View File

@ -1,7 +1,6 @@
using System.Diagnostics;
using System.IO;
using System.IO.Compression;
using System.Net;
using System.Net.Http;
using Microsoft.Win32;
@ -67,7 +66,7 @@ namespace Bloxstrap
"By default, two mod presets are provided for restoring the old death\n" +
"sound and the old mouse cursor.\n";
public static readonly HttpClient Client = new(new HttpClientHandler { AutomaticDecompression = DecompressionMethods.All });
private static readonly HttpClient Client = new();
private string? LaunchCommandLine;

View File

@ -104,16 +104,19 @@ namespace Bloxstrap.Helpers
string baseUrl = BuildBaseUrl(channel);
string lastDeploy = "";
string deployHistory = await Bootstrapper.Client.GetStringAsync($"{baseUrl}/DeployHistory.txt");
using (StringReader reader = new(deployHistory))
using (HttpClient client = new())
{
string? line;
string deployHistory = await client.GetStringAsync($"{baseUrl}/DeployHistory.txt");
while ((line = await reader.ReadLineAsync()) is not null)
using (StringReader reader = new(deployHistory))
{
if (line.Contains("WindowsPlayer"))
lastDeploy = line;
string? line;
while ((line = await reader.ReadLineAsync()) is not null)
{
if (line.Contains("WindowsPlayer"))
lastDeploy = line;
}
}
}

View File

@ -97,12 +97,15 @@ namespace Bloxstrap.Helpers.Integrations
Debug.WriteLine("Installing/Updating rbxfpsunlocker...");
byte[] bytes = await Bootstrapper.Client.GetByteArrayAsync(downloadUrl);
using (MemoryStream zipStream = new(bytes))
using (HttpClient client = new())
{
ZipArchive zip = new(zipStream);
zip.ExtractToDirectory(folderLocation, true);
byte[] bytes = await client.GetByteArrayAsync(downloadUrl);
using (MemoryStream zipStream = new(bytes))
{
ZipArchive zip = new(zipStream);
zip.ExtractToDirectory(folderLocation, true);
}
}
if (!File.Exists(settingsLocation))

View File

@ -75,8 +75,11 @@ namespace Bloxstrap.Helpers.RSMM
string pkgManifestUrl = $"{DeployManager.BaseUrl}/{versionGuid}-rbxPkgManifest.txt";
string pkgManifestData;
var getData = Bootstrapper.Client.GetStringAsync(pkgManifestUrl);
pkgManifestData = await getData.ConfigureAwait(false);
using (HttpClient http = new())
{
var getData = http.GetStringAsync(pkgManifestUrl);
pkgManifestData = await getData.ConfigureAwait(false);
}
return new PackageManifest(pkgManifestData);
}

View File

@ -15,15 +15,13 @@ namespace Bloxstrap.Helpers
public static async Task<T?> GetJson<T>(string url)
{
var request = await Bootstrapper.Client.SendAsync(new()
using (HttpClient client = new())
{
RequestUri = new Uri(url),
Headers = {
{ "User-Agent", Program.ProjectRepository }
}
});
var json = await request.Content.ReadAsStringAsync();
return JsonSerializer.Deserialize<T>(json);
client.DefaultRequestHeaders.Add("User-Agent", Program.ProjectRepository);
string json = await client.GetStringAsync(url);
return JsonSerializer.Deserialize<T>(json);
}
}
public static string MD5File(string filename)