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

Don't add "Vary: Accept-Encoding" header to the response if it's already exists #17

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Don't add "Vary: Accept-Encoding" header to the response if it's already exists #17

wants to merge 1 commit into from

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