BrotliResponsFilter similar to GzipResponseFilter · Issue #821 · omnifaces/omnifaces (original) (raw)
There is also a Google Java Brotli impl: https://github.com/google/brotli/blob/master/java/org/brotli/pom.xml
Apache Commons Compress has this: https://github.com/apache/commons-compress/tree/master/src/main/java/org/apache/commons/compress/compressors/brotli
I took a look but none of them have a "Brotli output stream", I could only find a BrotliInputStream
.
I found at least two libs having a "Brotli output stream"
- https://github.com/hyperxpro/Brotli4j (already mentioned by you)
- https://github.com/nixxcode/jvm-brotli
So I added a org.omnifaces.filter.CompressedResponseFilter
which supports these Brotli impls. Currently it's completely optional and it will fall back to Gzip or even further to Deflate (this is also new) when Brotli (or Gzip) is unavailable.
I tested following two Brotli impls:
com.nixxcode.jvmbrotli jvmbrotli 0.2.0 com.aayushatharva.brotli4j brotli4j 1.16.0It must be said that these were slightly slower than Gzip at my Linux machine with i9 10900x. Probably some HW/OS-related optimization missing as I noticed that these Brotli impls depend further on a bunch of native libs?
I would prefer an exception if the dependency / class was not found.
That's possible by explicitly telling the CompressedResponseFilter
that you want Brotli and nothing else.
Else it'll be automatic.