5

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?

Community
  • 1
  • 1
danf
  • 2,629
  • 21
  • 28

1 Answers1

2

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?

Community
  • 1
  • 1
danf
  • 2,629
  • 21
  • 28