Skip to content

Commit

Permalink
Merge pull request #17 from rcsb/dev-jd-gzip-encode
Browse files Browse the repository at this point in the history
Enable gzip transfer encoding for undertow/http
  • Loading branch information
josemduarte authored Sep 13, 2024
2 parents 0c5f1af + d0d28ff commit 1649029
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import io.undertow.server.HttpServerExchange;
import io.undertow.server.RoutingHandler;
import io.undertow.server.handlers.BlockingHandler;
import io.undertow.server.handlers.encoding.EncodingHandler;
import io.undertow.util.AttachmentKey;
import io.undertow.util.Headers;
import org.rcsb.idmapper.IdMapperServer;
Expand Down Expand Up @@ -52,9 +53,14 @@ public UndertowFrontendImpl(BackendImpl backend, int port, Gson m) {
}

public void initialize() {
// wrap it in an encodingHandler for gzip-encoded transfer support, see https://stackoverflow.com/a/46836820
HttpHandler encodingHandler = new EncodingHandler.Builder().build(null)
.wrap(rootHandler);

this.server = Undertow.builder()
.setServerOption(UndertowOptions.ENABLE_HTTP2, true)
.addHttpListener(port, "0.0.0.0", rootHandler)
.addHttpListener(port, "0.0.0.0")
.setHandler(encodingHandler)
.build();
}

Expand Down

0 comments on commit 1649029

Please sign in to comment.