Class EncodingFilter
- java.lang.Object
-
- org.glassfish.jersey.server.filter.EncodingFilter
-
- All Implemented Interfaces:
ContainerResponseFilter
@Priority(3000) public final class EncodingFilter extends Object implements 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_ACCEPTABLEresponse.The filter also ensures Accept-Encoding is added to the Vary header, for proper interaction with web caches.
- Author:
- Martin Matula
-
-
Constructor Summary
Constructors Constructor Description EncodingFilter()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static voidenableFor(ResourceConfig rc, Class<? extends ContentEncoder>... encoders)Enables this filter along with the providedencodersfor the suppliedResourceConfig.voidfilter(ContainerRequestContext request, ContainerResponseContext response)Filter method called after a response has been provided for a request (either by arequest filteror by a matched resource method.
-
-
-
Method Detail
-
enableFor
@SafeVarargs public static void enableFor(ResourceConfig rc, Class<? extends ContentEncoder>... encoders)
Enables this filter along with the providedencodersfor the suppliedResourceConfig.- Parameters:
rc- Resource config this filter should be enabled for.encoders- content encoders.
-
filter
public void filter(ContainerRequestContext request, ContainerResponseContext response) throws IOException
Description copied from interface:ContainerResponseFilterFilter method called after a response has been provided for a request (either by arequest filteror by a matched resource method.Filters in the filter chain are ordered according to their
jakarta.annotation.Priorityclass-level annotation value.- Specified by:
filterin interfaceContainerResponseFilter- Parameters:
request- request context.response- response context.- Throws:
IOException- if an I/O exception occurs.
-
-