Class EncodingFilter
- java.lang.Object
-
- org.glassfish.jersey.server.filter.EncodingFilter
-
- All Implemented Interfaces:
javax.ws.rs.container.ContainerResponseFilter
@Priority(3000) public final class EncodingFilter extends java.lang.Object implements javax.ws.rs.container.ContainerResponseFilter
Container filter that supports encoding-based content negotiation. The filter examines what content encodings are supported by the container (by looking up all theencoders
) 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 generatesResponse.Status.NOT_ACCEPTABLE
response.The filter also ensures Accept-Encoding is added to the Vary header, for proper interaction with web caches.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
EncodingFilter.ContentEncoding
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String
IDENTITY_ENCODING
private InjectionManager
injectionManager
private java.util.SortedSet<java.lang.String>
supportedEncodings
-
Constructor Summary
Constructors Constructor Description EncodingFilter()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static void
enableFor(ResourceConfig rc, java.lang.Class<? extends ContentEncoder>... encoders)
Enables this filter along with the providedencoders
for the suppliedResourceConfig
.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.
-
-
-
Field Detail
-
IDENTITY_ENCODING
private static final java.lang.String IDENTITY_ENCODING
- See Also:
- Constant Field Values
-
injectionManager
@Inject private InjectionManager injectionManager
-
supportedEncodings
private volatile java.util.SortedSet<java.lang.String> supportedEncodings
-
-
Method Detail
-
enableFor
@SafeVarargs public static void enableFor(ResourceConfig rc, java.lang.Class<? extends ContentEncoder>... encoders)
Enables this filter along with the providedencoders
for the suppliedResourceConfig
.- Parameters:
rc
- Resource config this filter should be enabled for.encoders
- content encoders.
-
filter
public void filter(javax.ws.rs.container.ContainerRequestContext request, javax.ws.rs.container.ContainerResponseContext response) throws java.io.IOException
- Specified by:
filter
in interfacejavax.ws.rs.container.ContainerResponseFilter
- Throws:
java.io.IOException
-
getSupportedEncodings
java.util.SortedSet<java.lang.String> getSupportedEncodings()
Returns a (lexically) sorted set of supported encodings.- Returns:
- sorted set of supported encodings.
-
-