How to get the wrong jersey headlines

I use Jersey 1.12 and have an endpoint that may or may not receive invalid headers from clients that I do not control (for example, "Content-Type":"application/json; bla-bla" ). Obviously, bla-bla distorted, since spec requires that the parameters have values, namely bla-bla=value , and thus Jersey outputs something like

 "status": 400, "message": "Bad Content-Type header value: 'application/json; bla-bla'" 

I can write a filter to solve this problem, as suggested here , here and here , but I wonder if there is a way to get Jersey to just ignore the error header together in cases where I am not interested in its meaning?

+5
source share
1 answer

Since there seems to be no solution for this, I ended up wrapping the ServletRequest in one of our application filters, such as what was suggested here , so that it returns the modified header where necessary.

As a workaround, I think it's fine and not very intrusive, but I'm still wondering if there is a better way?

+2
source

All Articles