HttpHeadersImpl implements HttpHeaders { @Override public List<Locale> getAcceptableLanguages() { List<String> values = nettyHttpHeaders.getAll(HttpHeaders.ACCEPT_LANGUAGE); if (values.isEmpty()) { return Collections.singletonList(new Locale("*")); } List<Locale> localeValues = new ArrayList<>(); Map<Locale, Float> prefs = new HashMap<>(); for (String value : values) { String[] pair = value != null ? value.split(";") : new String[0]; Locale locale = new Locale(pair[0].trim()); localeValues.add(locale); if (pair.length > 1) { String[] pair2 = pair[1] != null ? pair[1].split("=") : new String[0]; if (pair2.length > 1) { prefs.put(locale, getLanguageQualityFactor(pair2[1].trim())); } else { prefs.put(locale, 1F); } } else { prefs.put(locale, 1F); } } if (localeValues.size() <= 1) { return localeValues; } localeValues.sort(new AcceptLanguageComparator(prefs)); return localeValues; } HttpHeadersImpl(io.netty.handler.codec.http.HttpHeaders httpHeaders); @Override List<String> getRequestHeader(String name); @Override String getHeaderString(String name); @Override MultivaluedMap<String, String> getRequestHeaders(); @Override List<MediaType> getAcceptableMediaTypes(); @Override List<Locale> getAcceptableLanguages(); @Override MediaType getMediaType(); @Override Locale getLanguage(); @Override Map<String, Cookie> getCookies(); @Override Date getDate(); @Override int getLength();  }
@Test public void testGetAcceptableLanguages() throws Exception { List<Locale> locales = httpHeaders1.getAcceptableLanguages(); assertEquals(locales.size(), 3); assertEquals(locales.get(0).getLanguage(), "da"); assertEquals(locales.get(1).getLanguage(), "en-gb"); assertEquals(locales.get(2).getLanguage(), "en"); locales = httpHeaders2.getAcceptableLanguages(); assertEquals(locales.size(), 1); assertEquals(locales.get(0).getLanguage(), "*"); }