mirror of
https://github.com/Athou/commafeed.git
synced 2026-10-16 09:21:11 +00:00
add support for brotli compression
This commit is contained in:
@@ -465,6 +465,10 @@
|
||||
<groupId>com.github.luben</groupId>
|
||||
<artifactId>zstd-jni</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.aayushatharva.brotli4j</groupId>
|
||||
<artifactId>brotli4j</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.seancfoley</groupId>
|
||||
<artifactId>ipaddress</artifactId>
|
||||
|
||||
@@ -6,8 +6,6 @@ import com.codahale.metrics.Histogram;
|
||||
import com.codahale.metrics.Meter;
|
||||
import com.codahale.metrics.MetricRegistry;
|
||||
import com.codahale.metrics.Timer;
|
||||
import com.oracle.svm.core.annotate.Substitute;
|
||||
import com.oracle.svm.core.annotate.TargetClass;
|
||||
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
@@ -348,14 +346,4 @@ import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
com.rometools.opml.feed.synd.impl.ConverterForOPML10.class,
|
||||
com.rometools.opml.feed.synd.impl.ConverterForOPML20.class,
|
||||
})
|
||||
public class NativeImageClasses {
|
||||
|
||||
// disable brotli runtime detection because it causes native image failure
|
||||
@TargetClass(className = "org.apache.hc.client5.http.impl.Brotli4jRuntime")
|
||||
static final class Brotli4jRuntime {
|
||||
@Substitute
|
||||
public static boolean available() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
public class NativeImageClasses {}
|
||||
|
||||
@@ -20,6 +20,7 @@ import nl.altindag.ssl.apache5.util.Apache5SslUtils;
|
||||
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.InflatingBrotliDataConsumer;
|
||||
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;
|
||||
@@ -92,6 +93,7 @@ public class HttpClientFactory {
|
||||
ContentCoding.DEFLATE.token(), d -> new InflatingAsyncDataConsumer(d, null));
|
||||
contentDecoderMap.put(ContentCoding.GZIP.token(), InflatingGzipDataConsumer::new);
|
||||
contentDecoderMap.put(ContentCoding.ZSTD.token(), InflatingZstdDataConsumer::new);
|
||||
contentDecoderMap.put(ContentCoding.BROTLI.token(), InflatingBrotliDataConsumer::new);
|
||||
|
||||
RedirectStrategy redirectStrategy =
|
||||
config.httpClient().blockLocalAddresses()
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.commafeed.backend;
|
||||
|
||||
import com.aayushatharva.brotli4j.encoder.BrotliOutputStream;
|
||||
import com.codahale.metrics.MetricRegistry;
|
||||
import com.commafeed.CommaFeedConfiguration;
|
||||
import com.commafeed.CommaFeedVersion;
|
||||
@@ -418,7 +419,7 @@ class HttpGetterTest {
|
||||
@Nested
|
||||
class Compression {
|
||||
|
||||
private static final String ACCEPT_ENCODING = "deflate, gzip, zstd";
|
||||
private static final String ACCEPT_ENCODING = "deflate, gzip, zstd, br";
|
||||
|
||||
@Test
|
||||
void gzip() throws Exception {
|
||||
@@ -435,6 +436,11 @@ class HttpGetterTest {
|
||||
supportsCompression("zstd", ZstdOutputStream::new);
|
||||
}
|
||||
|
||||
@Test
|
||||
void br() throws Exception {
|
||||
supportsCompression("br", BrotliOutputStream::new);
|
||||
}
|
||||
|
||||
void supportsCompression(String encoding, CompressionFunction compressionFunction)
|
||||
throws Exception {
|
||||
String body = "my body";
|
||||
|
||||
Reference in New Issue
Block a user