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;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
|
using System.Net.Http.Headers;
|
||||||
|
|
||||||
|
using Dalamud.Utility;
|
||||||
|
|
||||||
namespace Dalamud.Networking.Http;
|
namespace Dalamud.Networking.Http;
|
||||||
|
|
||||||
|
|
@ -25,7 +28,16 @@ internal class HappyHttpClient : IDisposable, IServiceType
|
||||||
{
|
{
|
||||||
AutomaticDecompression = DecompressionMethods.All,
|
AutomaticDecompression = DecompressionMethods.All,
|
||||||
ConnectCallback = this.SharedHappyEyeballsCallback.ConnectCallback,
|
ConnectCallback = this.SharedHappyEyeballsCallback.ConnectCallback,
|
||||||
});
|
})
|
||||||
|
{
|
||||||
|
DefaultRequestHeaders =
|
||||||
|
{
|
||||||
|
UserAgent =
|
||||||
|
{
|
||||||
|
new ProductInfoHeaderValue("Dalamud", Util.AssemblyVersion),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,8 @@ using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.IO.Compression;
|
using System.IO.Compression;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Net.Http;
|
||||||
|
using System.Net.Http.Headers;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
@ -1196,7 +1198,17 @@ internal partial class PluginManager : IDisposable, IServiceType
|
||||||
private async Task<Stream> DownloadPluginAsync(RemotePluginManifest repoManifest, bool useTesting)
|
private async Task<Stream> DownloadPluginAsync(RemotePluginManifest repoManifest, bool useTesting)
|
||||||
{
|
{
|
||||||
var downloadUrl = useTesting ? repoManifest.DownloadLinkTesting : repoManifest.DownloadLinkInstall;
|
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();
|
response.EnsureSuccessStatusCode();
|
||||||
|
|
||||||
return await response.Content.ReadAsStreamAsync();
|
return await response.Content.ReadAsStreamAsync();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue