org.glassfish.jersey.server.filter

## Class EncodingFilter

- java.lang.Object
- - org.glassfish.jersey.server.filter.EncodingFilter

All Implemented Interfaces:
  jakarta.ws.rs.container.ContainerResponseFilter

    @Priority(value=3000)
    public final class EncodingFilter
    extends Object
    implements jakarta.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 the `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.

Author:
  Martin Matula

### Constructor Summary

Constructors
Constructor and Description
`EncodingFilter()`

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`static void` `enableFor(ResourceConfig rc, Class<? extends ContentEncoder>... encoders)` Enables this filter along with the provided `encoders` for the supplied `ResourceConfig`.
`void` `filter(jakarta.ws.rs.container.ContainerRequestContext request, jakarta.ws.rs.container.ContainerResponseContext response)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### EncodingFilter

    public EncodingFilter()

### Method Detail

#### enableFor

    @SafeVarargs
    public static void enableFor(ResourceConfig rc,
                                              Class<? extends ContentEncoder>... encoders)

Enables this filter along with the provided `encoders` for the supplied `ResourceConfig`.

Parameters:
  `rc` - Resource config this filter should be enabled for.
  `encoders` - content encoders.

#### filter

    public void filter(jakarta.ws.rs.container.ContainerRequestContext request,
                       jakarta.ws.rs.container.ContainerResponseContext response)
                throws IOException

Specified by:
  `filter` in interface `jakarta.ws.rs.container.ContainerResponseFilter`
Throws:
  `IOException`