log what happens when we fail to compress

This commit is contained in:
Athou
2026-10-15 03:07:43 +02:00
parent 0653e2dc97
commit ffb4a43e38

View File

@@ -13,6 +13,8 @@ import com.google.common.net.HttpHeaders;
import io.quarkus.runtime.configuration.MemorySize; import io.quarkus.runtime.configuration.MemorySize;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.apache.hc.client5.http.ConnectTimeoutException; import org.apache.hc.client5.http.ConnectTimeoutException;
import org.apache.hc.core5.http.HttpStatus; import org.apache.hc.core5.http.HttpStatus;
@@ -48,6 +50,7 @@ import java.util.concurrent.atomic.AtomicInteger;
import java.util.zip.DeflaterOutputStream; import java.util.zip.DeflaterOutputStream;
import java.util.zip.GZIPOutputStream; import java.util.zip.GZIPOutputStream;
@Slf4j
class HttpGetterTest { class HttpGetterTest {
private static final Instant NOW = Instant.now(); private static final Instant NOW = Instant.now();
@@ -450,13 +453,15 @@ class HttpGetterTest {
.when(HttpRequest.request().withMethod("GET")) .when(HttpRequest.request().withMethod("GET"))
.respond( .respond(
req -> { req -> {
try {
String acceptEncodingHeader = String acceptEncodingHeader =
req.getFirstHeader(HttpHeaders.ACCEPT_ENCODING); req.getFirstHeader(HttpHeaders.ACCEPT_ENCODING);
if (!ACCEPT_ENCODING.equals(acceptEncodingHeader)) { if (!ACCEPT_ENCODING.equals(acceptEncodingHeader)) {
throw new Exception( throw new Exception(
"Wrong value in the Accept-Encoding header, should be '%s' but was '%s'" "Wrong value in the Accept-Encoding header, should be '%s' but was '%s'"
.formatted( .formatted(
ACCEPT_ENCODING, acceptEncodingHeader)); ACCEPT_ENCODING,
acceptEncodingHeader));
} }
ByteArrayOutputStream output = new ByteArrayOutputStream(); ByteArrayOutputStream output = new ByteArrayOutputStream();
@@ -468,6 +473,10 @@ class HttpGetterTest {
return HttpResponse.response() return HttpResponse.response()
.withBody(output.toByteArray()) .withBody(output.toByteArray())
.withHeader(HttpHeaders.CONTENT_ENCODING, encoding); .withHeader(HttpHeaders.CONTENT_ENCODING, encoding);
} catch (Exception e) {
log.error("Error in compression callback", e);
throw e;
}
}); });
HttpResult result = getter.get(HttpGetterTest.this.feedUrl); HttpResult result = getter.get(HttpGetterTest.this.feedUrl);