I have a Spring boot (tomcat) REST controller declared as produces = "text/plain"
. My application uses spring security. If I send a request that will result in a 403 then the default spring boot json error handler will try to return a Content-Type
of application/json
.
This results in the client actually getting a 406
error org.springframework.web.HttpMediaTypeNotAcceptableException
because the client specified Accept: text/plain
in the request.
The obvious answer is to ask the client to specify two Accept
headers with text/plain
and application/json
. Doesn't work, you still get the 406
. Doesn't work either with a single, multi-valued header separated by commas.
In all cases the 403
survives all the way to StandardHostValve.status()
along with the two Accept
headers in the request but fails somewhere in the default error page forwarder.
Any ideas?