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.Diagnostics;
using System.IO; using System.IO;
using System.IO.Compression; using System.IO.Compression;
using System.Net;
using System.Net.Http; using System.Net.Http;
using Microsoft.Win32; using Microsoft.Win32;
@ -67,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";
public static readonly HttpClient Client = new(new HttpClientHandler { AutomaticDecompression = DecompressionMethods.All }); private static readonly HttpClient Client = new();
private string? LaunchCommandLine; private string? LaunchCommandLine;

View File

@ -104,16 +104,19 @@ namespace Bloxstrap.Helpers
string baseUrl = BuildBaseUrl(channel); string baseUrl = BuildBaseUrl(channel);
string lastDeploy = ""; string lastDeploy = "";
string deployHistory = await Bootstrapper.Client.GetStringAsync($"{baseUrl}/DeployHistory.txt"); using (HttpClient client = new())
using (StringReader reader = new(deployHistory))
{ {
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")) string? line;
lastDeploy = 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..."); Debug.WriteLine("Installing/Updating rbxfpsunlocker...");
byte[] bytes = await Bootstrapper.Client.GetByteArrayAsync(downloadUrl); using (HttpClient client = new())
using (MemoryStream zipStream = new(bytes))
{ {
ZipArchive zip = new(zipStream); byte[] bytes = await client.GetByteArrayAsync(downloadUrl);
zip.ExtractToDirectory(folderLocation, true);
using (MemoryStream zipStream = new(bytes))
{
ZipArchive zip = new(zipStream);
zip.ExtractToDirectory(folderLocation, true);
}
} }
if (!File.Exists(settingsLocation)) if (!File.Exists(settingsLocation))

View File

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

View File

@ -15,15 +15,13 @@ namespace Bloxstrap.Helpers
public static async Task<T?> GetJson<T>(string url) public static async Task<T?> GetJson<T>(string url)
{ {
var request = await Bootstrapper.Client.SendAsync(new() using (HttpClient client = new())
{ {
RequestUri = new Uri(url), 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)