0

We are trying to return content-length on a server running JAX-RS on every endpoint.

There are already some solutions based on adding the information on each endpoint, like here. However, this implementation is not very convenient as it requires editing each and every endpoint.

Is there a more straightforward way to make Jersey return content-length on every endpoint?

We also found this potential solution, but we are not sure how to generate a ServletResponseWrapper

Thank you!

buzoherbert
  • 1,537
  • 1
  • 12
  • 34

1 Answers1

0

JAX-RS implementations by default add a Content-Length header if your endpoints have the following signature:

@GET
public SomeEntity get () {
    return X;
}

If you want, you can use Servlet filters because JAX-RS is built on top of servlets.

The only case where JAX-RS does not add a Content-Length header is if I return StreamingOutput.

sudhir shakya
  • 827
  • 1
  • 9
  • 21