danf
danf

Reputation: 2709

How to have Jersey pass malformed headers

I'm using Jersey 1.12 and have an endpoint that may or may not receive malformed headers from clients that i don't control (for instance "Content-Type":"application/json; bla-bla") Obviously bla-bla is malformed as the spec requires parameters to have values as well i.e. bla-bla=value and thus Jersey will output something like

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

I can write a filter to tackle this as suggested here, here and here but I wonder if there's a way to have Jersey just ignore the malformed header all together in cases where i'm not interested in it's value?

Upvotes: 5

Views: 308

Answers (1)

danf
danf

Reputation: 2709

Since there's apparently no solution for this I ended up wrapping the ServletRequest in one of our application's filters kinda like what's suggested here to have it return a modified header where needed.

As a workaround I guess it's fine and not very intrusive but I still wonder if there was a better way?

Upvotes: 2

Related Questions