Description
Daniel Fernández opened SPR-14536 and commented
Now that content negotiation is in place at the View
/ViewResolver
mechanism and therefore View
implementations don't need to manually create the Content-Type
HTTP header, it would be nice to have a similar mechanism that avoided the manual creation of the Content-Language
header.
The current code at the reactive version of ThymeleafView
(see here) does something like:
final HttpHeaders responseHeaders = exchange.getResponse().getHeaders();
if (templateLocale != null) {
responseHeaders.set("Content-Language", templateLocale.toString());
}
However, in Spring MVC thanks to the HttpServletResponse#setLocale(Locale)
method, all it had to do is:
response.setLocale(templateLocale);
It's not that creating this header is extremely ugly code, but anyway IMHO it would be great if Spring Reactive included some kind of higher-level mechanism for setting this Content-Language
that kept View
implementations from having to create it manually.
Affects: 5.0 M1
Issue Links:
- Content-Language not set for responses rendered with Message Converters [SPR-14802] #19368 Content-Language not set for responses rendered with Message Converters
- Add HttpHeaders getter and setter for Accept-Language [SPR-15024] #19591 Add HttpHeaders getter and setter for Accept-Language
- Overloaded convenience setters on HttpHeaders [SPR-16562] #21104 Overloaded convenience setters on HttpHeaders
Referenced from: commits 36da299