Compare commits

...

2 Commits

Author SHA1 Message Date
Anna 6e048b0987
fix(client): dispose of HttpClient 2023-10-08 20:53:53 -04:00
Anna 12f564cc6d
fix(client): only send gzip if it's smaller 2023-10-08 20:53:45 -04:00
1 changed files with 18 additions and 4 deletions

View File

@ -12,7 +12,7 @@ using MessagePack;
namespace MegaMappingway;
public class Plugin : IDalamudPlugin {
public sealed class Plugin : IDalamudPlugin {
[PluginService]
internal static IPluginLog Log { get; private set; }
@ -49,6 +49,7 @@ public class Plugin : IDalamudPlugin {
this.Ui.Dispose();
this.Framework.Update -= this.FrameworkUpdate;
this.Hasher.Dispose();
this.Http.Dispose();
}
internal void SaveConfig() {
@ -112,13 +113,26 @@ public class Plugin : IDalamudPlugin {
await gz.FlushAsync();
}
var req = new HttpRequestMessage(HttpMethod.Post, "https://map.anna.lgbt/api/upload") {
Content = new ByteArrayContent(mem.ToArray()) {
var gzipped = mem.ToArray();
ByteArrayContent content;
if (gzipped.Length < msgpack.Length) {
content = new ByteArrayContent(gzipped) {
Headers = {
ContentType = new MediaTypeHeaderValue("application/msgpack"),
ContentEncoding = { "gzip" },
},
},
};
} else {
content = new ByteArrayContent(msgpack) {
Headers = {
ContentType = new MediaTypeHeaderValue("application/msgpack"),
},
};
}
var req = new HttpRequestMessage(HttpMethod.Post, "https://map.anna.lgbt/api/upload") {
Content = content,
};
try {