Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 749
danf Avatar asked Oct 31 '22 02:10

danf


1 Answers

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?

like image 53
danf Avatar answered Nov 15 '22 06:11

danf