Skip to content

Add HttpHeaders getter and setter for Content-Language [SPR-14536] #19105

Closed
@spring-projects-issues

Description

@spring-projects-issues

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:

Referenced from: commits 36da299

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions