Add HttpHeaders#setAcceptLanguageAsLocale(Locale)
Issue: SPR-15024
This commit is contained in:
@@ -475,6 +475,15 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
/**
|
||||
* A variant of {@link #setAcceptLanguage(List)} that sets the {@literal Accept-Language}
|
||||
* header value to the specified locale.
|
||||
* @since 5.0
|
||||
*/
|
||||
public void setAcceptLanguageAsLocale(Locale locale) {
|
||||
setAcceptLanguage(Collections.singletonList(new Locale.LanguageRange(locale.toLanguageTag())));
|
||||
}
|
||||
|
||||
/**
|
||||
* A variant of {@link #getAcceptLanguage()} that converts each
|
||||
* {@link java.util.Locale.LanguageRange} to a {@link Locale} and returns
|
||||
|
||||
Reference in New Issue
Block a user