mirror of
https://github.com/Athou/commafeed.git
synced 2026-10-30 08:56:07 +00:00
log what happens when we fail to compress
This commit is contained in:
@@ -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,24 +453,30 @@ class HttpGetterTest {
|
|||||||
.when(HttpRequest.request().withMethod("GET"))
|
.when(HttpRequest.request().withMethod("GET"))
|
||||||
.respond(
|
.respond(
|
||||||
req -> {
|
req -> {
|
||||||
String acceptEncodingHeader =
|
try {
|
||||||
req.getFirstHeader(HttpHeaders.ACCEPT_ENCODING);
|
String acceptEncodingHeader =
|
||||||
if (!ACCEPT_ENCODING.equals(acceptEncodingHeader)) {
|
req.getFirstHeader(HttpHeaders.ACCEPT_ENCODING);
|
||||||
throw new Exception(
|
if (!ACCEPT_ENCODING.equals(acceptEncodingHeader)) {
|
||||||
"Wrong value in the Accept-Encoding header, should be '%s' but was '%s'"
|
throw new Exception(
|
||||||
.formatted(
|
"Wrong value in the Accept-Encoding header, should be '%s' but was '%s'"
|
||||||
ACCEPT_ENCODING, acceptEncodingHeader));
|
.formatted(
|
||||||
}
|
ACCEPT_ENCODING,
|
||||||
|
acceptEncodingHeader));
|
||||||
|
}
|
||||||
|
|
||||||
ByteArrayOutputStream output = new ByteArrayOutputStream();
|
ByteArrayOutputStream output = new ByteArrayOutputStream();
|
||||||
try (OutputStream compressionOutputStream =
|
try (OutputStream compressionOutputStream =
|
||||||
compressionFunction.apply(output)) {
|
compressionFunction.apply(output)) {
|
||||||
compressionOutputStream.write(body.getBytes());
|
compressionOutputStream.write(body.getBytes());
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
|
|||||||
Reference in New Issue
Block a user