fix(client): only send gzip if it's smaller

This commit is contained in:
Anna 2023-10-08 20:53:21 -04:00
parent 5ac8041f19
commit 12f564cc6d
Signed by: anna
GPG Key ID: D0943384CD9F87D1
1 changed files with 16 additions and 3 deletions

View File

@ -112,13 +112,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 {