According to https://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#how-to-enable-http-response-compression
webflux with netty server currently doesn't support compression.
@bclozel given that it's blocked and not scheduled for reactor-netty 0.8.0, I think this one should be postponed.
@snicoll reactor-netty supports server compression with only one option: the minimum response size (see HttpServerOptions). We can provide that support.
To be on par with the other servers, we'd need reactor/reactor-netty#218.
We decided to go ahead and support compression with just the minimum size option available.
Can you provide an example of a Reactive @RestController to get it to properly gzip responses? Setting server.compression.enabled=true doesn't seem to do anything but add a content-encoding: gzip response header. The response itself is not gzipped.
I have an endpoint that returns a gzip file that I was compressing myself using GZIPOutputStream like so:
@GetMapping(path = "/something/{variable}", produces = "application/gzip")
public ResponseEntity<Flux<byte[]>> getGzipFile(@PathVariable("variable") String variable) {
Flux<byte[]> results = generatorService.generateGzipFile(variable);
return ResponseEntity.ok()
.header("Content-Disposition", "attachment; filename=" + variable + ".gz")
.body(results);
}
This worked pretty well, but I figured I'd try to let the Netty handle the compression so I don't have to deal with managing streams, compression, and byte arrays myself.
I took out the compression code in my generatorService and enabled the compression server setting and my responses were not gzipped. I did add application/gzip as a mime type as well in the server compression settings.
@ealexhaywood Could you create a new issue for that with a sample application showing this problem?
I would guess that this behaviour is due to https://github.com/reactor/reactor-netty/issues/411 which would make this a duplicate of #12892.
Possibly, although I am not enabling compression via Predicates (unless that is what enabling compression in application.properties is doing) nor are my resources static. I generate resources dynamically, write them to a Flux sink as they are created, and stream the response to the client.
unless that is what enabling compression in application.properties is doing
It is.
nor are my resources static
I don't think that matters.
Oh okay great, so it seems like it has been addressed and will be in your 0.7.9.RELEASE sometime soon. About how long will it takes for this to make its way into a Spring Boot release?
Most helpful comment
Spring Boot 2.0.5 is scheduled for next week.