Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serve raw content compressed if suitable #33

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/main/java/tfb/status/handler/DownloadResultsHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
import io.undertow.server.handlers.PathHandler;
import io.undertow.server.handlers.resource.PathResourceManager;
import io.undertow.server.handlers.resource.ResourceHandler;
import io.undertow.server.handlers.encoding.ContentEncodingRepository;
import io.undertow.server.handlers.encoding.EncodingHandler;
import io.undertow.server.handlers.encoding.GzipEncodingProvider;
import jakarta.inject.Singleton;
import java.util.Objects;
import org.glassfish.hk2.extras.provides.Provides;
Expand Down Expand Up @@ -35,6 +38,10 @@ public static HttpHandler downloadResultsHandler(FileStore fileStore) {

// Trim the "/raw" prefix from the front of the request path, since that
// prefix would confuse the ResourceHandler.
return new PathHandler().addPrefixPath("/raw", resourceHandler);
var pathHandler = new PathHandler().addPrefixPath("/raw", resourceHandler);

var encodingRepository = new ContentEncodingRepository().addEncodingHandler("gzip", new GzipEncodingProvider(), 50);

return new EncodingHandler(encodingRepository).setNext(pathHandler);
}
}