Accept header not parsed in standard way, causing incorrect type of response to be issued
This is a huge issue in how the accepted media type is selected. If text/html appears anywhere in the value, it is preferred, even if that's not the case!
This means that the value application/json; q=1.0, text/html; q=0.9, */*; q=0.1 in Accept, which means "give me JSON first, HTML if that doesn't exist and anything else if you have neither" is interpreted by Ninja as "give me HTML".
According to the code in AbstractContext.getAcceptContentType, the following is the order in which the media type is selected, without the user-specified order:
- HTML
- XML
- JSON
- Plain Text
- application/octet-stream
- If none of the above, HTML
Hi @omervk,
I haven't explored the content negotiation features of Ninja yet, but I think its a bit less straight forward than this single method. I think Ninja has another part of the code that helps pick the type your result renders to. http://www.ninjaframework.org/documentation/content_negotiation.html
Ninja is a community effort, so if you wanted to submit a PR that enhances/improves/fixes it, I'd be happy to take a look.
@jjlauer,
Yes, I've seen this part of Ninja and have placed my comments in another issue, #487.
I'll see if I can contribute code for any of the three issues I opened. :+1: