mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 18:27:23 +01:00
Send Dalamud user-agent when downloading plugins (#1550)
Sets the user-agent on all HappyHttp requests to `Dalamud/<Version>`, and pass `Accept: application/zip` in plugin downloads.
This commit is contained in:
parent
473e24301d
commit
fcebd15077
2 changed files with 26 additions and 2 deletions
|
|
@ -1,6 +1,9 @@
|
|||
using System;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
|
||||
using Dalamud.Utility;
|
||||
|
||||
namespace Dalamud.Networking.Http;
|
||||
|
||||
|
|
@ -25,7 +28,16 @@ internal class HappyHttpClient : IDisposable, IServiceType
|
|||
{
|
||||
AutomaticDecompression = DecompressionMethods.All,
|
||||
ConnectCallback = this.SharedHappyEyeballsCallback.ConnectCallback,
|
||||
});
|
||||
})
|
||||
{
|
||||
DefaultRequestHeaders =
|
||||
{
|
||||
UserAgent =
|
||||
{
|
||||
new ProductInfoHeaderValue("Dalamud", Util.AssemblyVersion),
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ using System.Diagnostics;
|
|||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
|
@ -1196,7 +1198,17 @@ internal partial class PluginManager : IDisposable, IServiceType
|
|||
private async Task<Stream> DownloadPluginAsync(RemotePluginManifest repoManifest, bool useTesting)
|
||||
{
|
||||
var downloadUrl = useTesting ? repoManifest.DownloadLinkTesting : repoManifest.DownloadLinkInstall;
|
||||
var response = await this.happyHttpClient.SharedHttpClient.GetAsync(downloadUrl);
|
||||
var request = new HttpRequestMessage(HttpMethod.Get, downloadUrl)
|
||||
{
|
||||
Headers =
|
||||
{
|
||||
Accept =
|
||||
{
|
||||
new MediaTypeWithQualityHeaderValue("application/zip"),
|
||||
},
|
||||
},
|
||||
};
|
||||
var response = await this.happyHttpClient.SharedHttpClient.SendAsync(request);
|
||||
response.EnsureSuccessStatusCode();
|
||||
|
||||
return await response.Content.ReadAsStreamAsync();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue