feat(plugin): compress data
This commit is contained in:
parent
944110d052
commit
a4a516e1c3
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue