This filter may compress with brotli the responses for any requests that aren't HEAD requests and specify an accept encoding of brotli.
It won't compresss under the following conditions:
- The response code is 204 or 304 (these codes MUST NOT contain a body, and an empty compressed response is 20 bytes
long)
- The response already defines a Content-Encoding header
- A custom shouldBrotli function is supplied and it returns false
Since compressing changes the content length of the response, this filter may do some buffering - it will buffer any
streamed responses that define a content length less than the configured chunked threshold. Responses that are
greater in length, or that don't define a content length, will not be buffered, but will be sent as chunked
responses.
Annotations
@Singleton()
Linear Supertypes
EssentialFilter, AnyRef, Any
Ordering
Alphabetic
By Inheritance
Inherited
BrotliFilter
EssentialFilter
AnyRef
Any
Hide All
Show All
Visibility
Public
All
Instance Constructors
newBrotliFilter(quality: Int = 5, chunkedThreshold: Int = 102400, shouldBrotli: (RequestHeader, Result) ⇒ Boolean = (_, _) => true)(implicit mat: Materializer)
A brotli filter.
This filter may compress with brotli the responses for any requests that aren't HEAD requests and specify an accept encoding of brotli.
It won't compresss under the following conditions:
- The response code is 204 or 304 (these codes MUST NOT contain a body, and an empty compressed response is 20 bytes long) - The response already defines a Content-Encoding header - A custom shouldBrotli function is supplied and it returns false
Since compressing changes the content length of the response, this filter may do some buffering - it will buffer any streamed responses that define a content length less than the configured chunked threshold. Responses that are greater in length, or that don't define a content length, will not be buffered, but will be sent as chunked responses.