mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 10:17:22 +01:00
Replace WebClient with HttpClient
This commit is contained in:
parent
d23ed9020a
commit
965f2142ff
2 changed files with 9 additions and 9 deletions
|
|
@ -359,16 +359,17 @@ namespace Dalamud.Plugin.Internal
|
|||
// ignored, since the plugin may be loaded already
|
||||
}
|
||||
|
||||
using var client = new WebClient();
|
||||
|
||||
var tempZip = new FileInfo(Path.GetTempFileName());
|
||||
|
||||
try
|
||||
{
|
||||
Log.Debug($"Downloading plugin to {tempZip} from {downloadUrl}");
|
||||
client.DownloadFile(downloadUrl, tempZip.FullName);
|
||||
using var client = new HttpClient();
|
||||
var response = client.GetAsync(downloadUrl).Result;
|
||||
using var fs = new FileStream(tempZip.FullName, FileMode.CreateNew);
|
||||
response.Content.CopyToAsync(fs).GetAwaiter().GetResult();
|
||||
}
|
||||
catch (WebException ex)
|
||||
catch (HttpRequestException ex)
|
||||
{
|
||||
Log.Error(ex, $"Download of plugin {repoManifest.Name} failed unexpectedly.");
|
||||
throw;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Dalamud.Logging.Internal;
|
||||
|
|
@ -74,11 +74,10 @@ namespace Dalamud.Plugin.Internal
|
|||
|
||||
return Task.Run(() =>
|
||||
{
|
||||
using var client = new WebClient();
|
||||
|
||||
Log.Information($"Fetching repo: {this.PluginMasterUrl}");
|
||||
|
||||
var data = client.DownloadString(this.PluginMasterUrl);
|
||||
using var client = new HttpClient();
|
||||
using var response = client.GetAsync(this.PluginMasterUrl).Result;
|
||||
var data = response.Content.ReadAsStringAsync().Result;
|
||||
|
||||
var pluginMaster = JsonConvert.DeserializeObject<List<RemotePluginManifest>>(data);
|
||||
pluginMaster.Sort((pm1, pm2) => pm1.Name.CompareTo(pm2.Name));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue