Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
spring-projects-issues opened this issue Jul 29, 2016 · 3 comments
Closed
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Jul 29, 2016

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

@spring-projects-issues
Copy link
Collaborator Author

Sébastien Deleuze commented

Rossen Stoyanchev I think I can take care of this one if you don't mind.

@spring-projects-issues
Copy link
Collaborator Author

Rossen Stoyanchev commented

It might make sense to start with support in HttpHeaders for Accept-Language and Content-Language accepting and returning Locale or List<Locale> in the case of Accept-Language.

That might even be all that needs to be done for this ticket since setContentLanguage can check the input locale for null.

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented Dec 15, 2016

Sébastien Deleuze commented

Fixed by this commit. See also #19591 that adds Accept-Language getter and setter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants