server.compression.enabled=true # response compression
The gzip encoding of HTTP request is quite different beast and it needs completely different approach.
First of all it is web-container specific - here is Spring configuration for Jetty using its GzipHandler:
@Component
public class JettyCustomizer implements
WebServerFactoryCustomizer<ConfigurableJettyWebServerFactory> {
@Override
public void customize(ConfigurableJettyWebServerFactory factory) {
public void customize(ConfigurableJettyWebServerFactory factory) {
factory.addServerCustomizers(server -> {
GzipHandler handler = new GzipHandler();
handler.setInflateBufferSize(2_048);
handler.setHandler(server.getHandler());
server.setHandler(handler);
});
}
}
The Inflate Buffer Size has to be set and the handler is able to gzip responses as well.
The Inflate Buffer Size has to be set and the handler is able to gzip responses as well.
The configuration can be tested using curl:
echo '{"foo":"bar"}' | gzip | curl --http1.1 -i -X POST http://localhost:8080/test -H "Content-type: application/json" -H "Content-Encoding: gzip" --data-binary @-