From 6b9f7c9aa51ba822833d888a9c0a913319aa8adb Mon Sep 17 00:00:00 2001
From: TeYroXOfficial <57874535+TeYroXOfficial@users.noreply.github.com>
Date: Wed, 16 Sep 2026 17:35:28 +0200
Subject: [PATCH 1/3] Handle gzip-compressed responses Http.getInputStream()
---
build.gradle.kts | 2 +-
util/src/main/java/eu/darkbot/util/http/Http.java | 15 +++++++++++++--
2 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/build.gradle.kts b/build.gradle.kts
index 08e3e447..e6a2df0f 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -21,7 +21,7 @@ dependencies {
api(project(":darkbot-shared"))
}
-val apiVersion = "0.9.9"
+val apiVersion = "0.9.11"
allprojects {
group = "eu.darkbot"
diff --git a/util/src/main/java/eu/darkbot/util/http/Http.java b/util/src/main/java/eu/darkbot/util/http/Http.java
index 008eb5f9..901d26bc 100644
--- a/util/src/main/java/eu/darkbot/util/http/Http.java
+++ b/util/src/main/java/eu/darkbot/util/http/Http.java
@@ -12,6 +12,7 @@
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
+import java.io.PushbackInputStream;
import java.lang.reflect.Type;
import java.net.HttpURLConnection;
import java.net.URL;
@@ -22,6 +23,7 @@
import java.util.List;
import java.util.Map;
import java.util.function.Consumer;
+import java.util.zip.GZIPInputStream;
/**
* Utility for HTTP connections.
@@ -291,9 +293,18 @@ public void closeInputStream() throws IOException {
* @throws IOException of {@link Http#getConnection()}
*/
public InputStream getInputStream() throws IOException {
- return getConnection().getInputStream();
+ PushbackInputStream in = new PushbackInputStream(getConnection().getInputStream(), 2);
+
+ byte[] header = new byte[2];
+ int count = in.read(header);
+ if (count > 0) in.unread(header, 0, count);
+
+ // Response may be gzip-compressed even without a Content-Encoding header
+ if (count == 2 && header[0] == 0x1f && header[1] == 0x8b) {
+ return new GZIPInputStream(in);
+ }
+ return in;
}
-
/**
* Gets InputStream of current connection and applies consumer then closes InputStream.
* Creates new connection on each call
From 7b22385b79506e9c971e1d882814a585032a3779 Mon Sep 17 00:00:00 2001
From: TeYroXOfficial <57874535+TeYroXOfficial@users.noreply.github.com>
Date: Wed, 16 Sep 2026 17:49:52 +0200
Subject: [PATCH 2/3] Update Http.java
---
util/src/main/java/eu/darkbot/util/http/Http.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/util/src/main/java/eu/darkbot/util/http/Http.java b/util/src/main/java/eu/darkbot/util/http/Http.java
index 901d26bc..12efce19 100644
--- a/util/src/main/java/eu/darkbot/util/http/Http.java
+++ b/util/src/main/java/eu/darkbot/util/http/Http.java
@@ -300,7 +300,7 @@ public InputStream getInputStream() throws IOException {
if (count > 0) in.unread(header, 0, count);
// Response may be gzip-compressed even without a Content-Encoding header
- if (count == 2 && header[0] == 0x1f && header[1] == 0x8b) {
+ if (count == 2 && header[0] == (byte) 0x1f && header[1] == (byte) 0x8b) {
return new GZIPInputStream(in);
}
return in;
From f0c8fc63e7155b63f6e7879f207d7197a01664e0 Mon Sep 17 00:00:00 2001
From: TeYroXOfficial <57874535+TeYroXOfficial@users.noreply.github.com>
Date: Wed, 16 Sep 2026 17:56:00 +0200
Subject: [PATCH 3/3] Update Http.java
---
util/src/main/java/eu/darkbot/util/http/Http.java | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/util/src/main/java/eu/darkbot/util/http/Http.java b/util/src/main/java/eu/darkbot/util/http/Http.java
index 12efce19..dba22a5b 100644
--- a/util/src/main/java/eu/darkbot/util/http/Http.java
+++ b/util/src/main/java/eu/darkbot/util/http/Http.java
@@ -32,7 +32,8 @@
public class Http {
private static final Gson GSON = new Gson();
- @Getter @Setter
+ @Getter
+ @Setter
private static String defaultUserAgent = "BigpointClient/1.6.7";
protected final String baseUrl;
@@ -298,13 +299,14 @@ public InputStream getInputStream() throws IOException {
byte[] header = new byte[2];
int count = in.read(header);
if (count > 0) in.unread(header, 0, count);
-
+
// Response may be gzip-compressed even without a Content-Encoding header
if (count == 2 && header[0] == (byte) 0x1f && header[1] == (byte) 0x8b) {
return new GZIPInputStream(in);
}
return in;
}
+
/**
* Gets InputStream of current connection and applies consumer then closes InputStream.
* Creates new connection on each call