Skip to content
This repository was archived by the owner on Jan 27, 2021. It is now read-only.

Conversation

@vadyalex
Copy link

GZIPContentEncodingFilter modifies response header by adding "Vary: Accept-Encoding" even if it's already exists.

This side effect behaviour may lead to nasty problems..

For example, there is an JAX-RS resource:

@Path("/myResource")
public class SomeResource {

    public static final Response OK = Response.ok().build();

    @GET
    public Response doGet() {
        return OK;
    }

}

Because Response class is mutable every time GZIPContentEncodingFilter processes request-response containers it will add "Vary: Accept-Encoding".

Since SomeResource.OK lives during application lifetime header size will grow until overgrows maximum header limit size allowed by underlying Servlet Container and application will not be able to process current resource.

@vadyalex
Copy link
Author

Even though I would say improper design of Response rather than improper use adding "Vary: Accept-Encoding" to the response object even if it's already there is a bug.

@vadyalex
Copy link
Author

Note that Jersey 2.0 shares my train of thought - do not add if it's already there.
Refer to correspondent code.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant