diff options
author | DeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com> | 2023-04-22 13:37:28 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-22 21:37:28 +1000 |
commit | b12f18fdbc60f141657ecfbd18590724666b593d (patch) | |
tree | 97ac0e2f3960cd77fe0983a2b1b41af6e5207ca0 /src/main | |
parent | 4c6da9bb41db05c08de564b47bbe52b93db71eb4 (diff) | |
download | NotEnoughUpdates-b12f18fdbc60f141657ecfbd18590724666b593d.tar.gz NotEnoughUpdates-b12f18fdbc60f141657ecfbd18590724666b593d.tar.bz2 NotEnoughUpdates-b12f18fdbc60f141657ecfbd18590724666b593d.zip |
Make ApiUtil accept gzip encoding (#677)
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/io/github/moulberry/notenoughupdates/util/ApiUtil.java | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/ApiUtil.java b/src/main/java/io/github/moulberry/notenoughupdates/util/ApiUtil.java index 3cb17772..0cda91fd 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/ApiUtil.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/ApiUtil.java @@ -70,12 +70,14 @@ public class ApiUtil { .thenComparing(NameValuePair::getValue); private static final ExecutorService executorService = Executors.newFixedThreadPool(3); + private static String getUserAgent() { if (NotEnoughUpdates.INSTANCE.config.hidden.customUserAgent != null) { return NotEnoughUpdates.INSTANCE.config.hidden.customUserAgent; } return "NotEnoughUpdates/" + NotEnoughUpdates.VERSION; } + private static SSLContext ctx; private final Map<String, CompletableFuture<Void>> updateTasks = new HashMap<>(); private static boolean notifiedOfInvalidApiKey; @@ -209,6 +211,9 @@ public class ApiUtil { if (this.postContentType != null) { conn.setRequestProperty("Content-Type", this.postContentType); } + if (!shouldGunzip) { + conn.setRequestProperty("Accept-Encoding", "gzip"); // Tell the server we can accept gzip + } if (this.postData != null) { conn.setDoOutput(true); OutputStream os = conn.getOutputStream(); @@ -221,7 +226,7 @@ public class ApiUtil { inputStream = conn.getInputStream(); - if (shouldGunzip) { + if (shouldGunzip || "gzip".equals(conn.getContentEncoding())) { inputStream = new GZIPInputStream(inputStream); } |