feat(plugin): compress data

This commit is contained in:
Anna 2023-10-05 01:06:14 -04:00
parent 944110d052
commit a4a516e1c3
Signed by: anna
GPG Key ID: D0943384CD9F87D1
1 changed files with 15 additions and 2 deletions

View File

@ -1,5 +1,7 @@
using System.Diagnostics;
using System.IO.Compression;
using System.Net.Http.Headers;
using System.Text;
using Dalamud.Game.ClientState.Objects.Enums;
using Dalamud.Game.ClientState.Objects.SubKinds;
using Dalamud.IoC;
@ -80,10 +82,21 @@ public class Plugin : IDalamudPlugin {
});
Task.Run(async () => {
var mem = new MemoryStream();
var gz = new GZipStream(mem, CompressionLevel.Optimal);
gz.Write(Encoding.UTF8.GetBytes(json));
gz.Flush();
var req = new HttpRequestMessage(HttpMethod.Post, "http://localhost:30888/upload") {
Content = new StringContent(json) {
Headers = { ContentType = new MediaTypeHeaderValue("application/json") },
Content = new ByteArrayContent(mem.ToArray()) {
Headers = {
ContentType = new MediaTypeHeaderValue("application/json"),
ContentEncoding = { "gzip" },
},
},
// Content = new StringContent(json) {
// Headers = { ContentType = new MediaTypeHeaderValue("application/json") },
// },
};
var resp = await this.Http.SendAsync(req);