diff --git a/commafeed-server/pom.xml b/commafeed-server/pom.xml
index 3d44caec..63ef07fb 100644
--- a/commafeed-server/pom.xml
+++ b/commafeed-server/pom.xml
@@ -461,6 +461,10 @@
ayza-for-apache5
10.1.0
+
+ com.github.luben
+ zstd-jni
+
com.github.seancfoley
ipaddress
diff --git a/commafeed-server/src/main/java/com/commafeed/NativeImageClasses.java b/commafeed-server/src/main/java/com/commafeed/NativeImageClasses.java
index bda41f0f..9fba6031 100644
--- a/commafeed-server/src/main/java/com/commafeed/NativeImageClasses.java
+++ b/commafeed-server/src/main/java/com/commafeed/NativeImageClasses.java
@@ -350,15 +350,7 @@ import io.quarkus.runtime.annotations.RegisterForReflection;
})
public class NativeImageClasses {
- // disable zstd and brotli runtime detection because it causes native image failure
- @TargetClass(className = "org.apache.hc.client5.http.impl.ZstdRuntime")
- static final class ZstdRuntime {
- @Substitute
- public static boolean available() {
- return false;
- }
- }
-
+ // disable brotli runtime detection because it causes native image failure
@TargetClass(className = "org.apache.hc.client5.http.impl.Brotli4jRuntime")
static final class Brotli4jRuntime {
@Substitute
diff --git a/commafeed-server/src/main/java/com/commafeed/backend/HttpClientFactory.java b/commafeed-server/src/main/java/com/commafeed/backend/HttpClientFactory.java
index 368c1e34..cea1dd98 100644
--- a/commafeed-server/src/main/java/com/commafeed/backend/HttpClientFactory.java
+++ b/commafeed-server/src/main/java/com/commafeed/backend/HttpClientFactory.java
@@ -21,6 +21,7 @@ import org.apache.hc.client5.http.DnsResolver;
import org.apache.hc.client5.http.SystemDefaultDnsResolver;
import org.apache.hc.client5.http.async.methods.InflatingAsyncDataConsumer;
import org.apache.hc.client5.http.async.methods.InflatingGzipDataConsumer;
+import org.apache.hc.client5.http.async.methods.InflatingZstdDataConsumer;
import org.apache.hc.client5.http.config.ConnectionConfig;
import org.apache.hc.client5.http.config.TlsConfig;
import org.apache.hc.client5.http.entity.compress.ContentCoding;
@@ -90,6 +91,7 @@ public class HttpClientFactory {
contentDecoderMap.put(
ContentCoding.DEFLATE.token(), d -> new InflatingAsyncDataConsumer(d, null));
contentDecoderMap.put(ContentCoding.GZIP.token(), InflatingGzipDataConsumer::new);
+ contentDecoderMap.put(ContentCoding.ZSTD.token(), InflatingZstdDataConsumer::new);
RedirectStrategy redirectStrategy =
config.httpClient().blockLocalAddresses()
diff --git a/commafeed-server/src/test/java/com/commafeed/backend/HttpGetterTest.java b/commafeed-server/src/test/java/com/commafeed/backend/HttpGetterTest.java
index 1d24ce55..73c0b207 100644
--- a/commafeed-server/src/test/java/com/commafeed/backend/HttpGetterTest.java
+++ b/commafeed-server/src/test/java/com/commafeed/backend/HttpGetterTest.java
@@ -7,6 +7,7 @@ import com.commafeed.backend.HttpGetter.HttpResponseException;
import com.commafeed.backend.HttpGetter.HttpResult;
import com.commafeed.backend.HttpGetter.NotModifiedException;
import com.commafeed.backend.HttpGetter.TooManyRequestsException;
+import com.github.luben.zstd.ZstdOutputStream;
import com.google.common.net.HttpHeaders;
import io.quarkus.runtime.configuration.MemorySize;
@@ -417,7 +418,7 @@ class HttpGetterTest {
@Nested
class Compression {
- private static final String ACCEPT_ENCODING = "deflate, gzip";
+ private static final String ACCEPT_ENCODING = "deflate, gzip, zstd";
@Test
void gzip() throws Exception {
@@ -429,6 +430,11 @@ class HttpGetterTest {
supportsCompression("deflate", DeflaterOutputStream::new);
}
+ @Test
+ void zstd() throws Exception {
+ supportsCompression("zstd", ZstdOutputStream::new);
+ }
+
void supportsCompression(String encoding, CompressionFunction compressionFunction)
throws Exception {
String body = "my body";