Currently, content negotiation is completely type-based and doesn't consider the actual value to be rendered.

My use case is as follows: Spring HATEOAS users usually work with RepresentationModel instances they return from controllers. Spring Data REST currently does so as well, and it has two different HttpMessageConverters registered, one for HAL and one for HAL FORMS. Whether the latter can reasonably be rendered depends on the state of the RepresentationModel and there is currently no way to filter the list of producible media types based on the value.

I've looked into ResponseBodyAdvice as it has access to all the moving parts I need, but I cannot throw a HttpMediaTypeNotAcceptableException from that one as the exception is a checked one. I need to be able to produce a 406 in case someone asks for HAL FORMS only but depending on the value to be rendered it cannot be produced properly.