@Priority(value=3000)
public final class EncodingFilter
extends java.lang.Object
implements javax.ws.rs.container.ContainerResponseFilter
encoders
) and decides what encoding should be chosen
based on the encodings listed in the Accept-Encoding request header and their associated quality values.
If none of the acceptable encodings is supported and identity encoding is explicitly forbidden by the client,
the filter generates Response.Status.NOT_ACCEPTABLE
response.
The filter also ensures Accept-Encoding is added to the Vary header, for proper interaction with web caches.
Modifier and Type | Class and Description |
---|---|
private static class |
EncodingFilter.ContentEncoding |
Modifier and Type | Field and Description |
---|---|
private static java.lang.String |
IDENTITY_ENCODING |
private InjectionManager |
injectionManager |
private java.util.SortedSet<java.lang.String> |
supportedEncodings |
Constructor and Description |
---|
EncodingFilter() |
Modifier and Type | Method and Description |
---|---|
static void |
enableFor(ResourceConfig rc,
java.lang.Class<? extends ContentEncoder>... encoders)
Enables this filter along with the provided
encoders
for the supplied ResourceConfig . |
void |
filter(javax.ws.rs.container.ContainerRequestContext request,
javax.ws.rs.container.ContainerResponseContext response) |
(package private) java.util.SortedSet<java.lang.String> |
getSupportedEncodings()
Returns a (lexically) sorted set of supported encodings.
|
private static final java.lang.String IDENTITY_ENCODING
@Inject private InjectionManager injectionManager
private volatile java.util.SortedSet<java.lang.String> supportedEncodings
@SafeVarargs public static void enableFor(ResourceConfig rc, java.lang.Class<? extends ContentEncoder>... encoders)
encoders
for the supplied ResourceConfig
.rc
- Resource config this filter should be enabled for.encoders
- content encoders.public void filter(javax.ws.rs.container.ContainerRequestContext request, javax.ws.rs.container.ContainerResponseContext response) throws java.io.IOException
filter
in interface javax.ws.rs.container.ContainerResponseFilter
java.io.IOException
java.util.SortedSet<java.lang.String> getSupportedEncodings()