@Test public void acceptedTypes() { HashRequestHeaders hs = withHeader(Http.Header.ACCEPT, "text/*;q=0.3, text/html;q=0.7, text/html;level=1, text/html;level=2;q=0.4"); assertThat(hs.acceptedTypes().size(), is(4)); assertThat(hs.acceptedTypes().get(0), is(createMt("text", "*", Map.of("q", "0.3")))); assertThat(hs.acceptedTypes().get(0).qualityFactor(), IsCloseTo.closeTo(0, 0.3)); assertThat(hs.acceptedTypes().get(1), is(createMt("text", "html", Map.of("q", "0.7")))); assertThat(hs.acceptedTypes().get(2), is(createMt("text", "html", Map.of("level", "1")))); assertThat(hs.acceptedTypes().get(3), is(createMt("text", "html", Map.of("level", "2", "q", "0.4")))); }
@Override public List<MediaType> acceptedTypes() { List<MediaType> result = this.acceptedtypesCache; if (result == null) { List<String> acceptValues = all(Http.Header.ACCEPT); if (acceptValues.size() == 1 && HUC_ACCEPT_DEFAULT.equals(acceptValues.get(0))) { result = HUC_ACCEPT_DEFAULT_TYPES; } else { result = LazyList.create(acceptValues.stream() .flatMap(h -> Utils.tokenize(',', "\"", false, h).stream()) .map(String::trim) .map(s -> LazyValue.create(() -> MediaType.parse(s))) .collect(Collectors.toList())); } result = Collections.unmodifiableList(result); this.acceptedtypesCache = result; } return result; }
HashRequestHeaders extends ReadOnlyParameters implements RequestHeaders { @Override public List<MediaType> acceptedTypes() { List<MediaType> result = this.acceptedtypesCache; if (result == null) { List<String> acceptValues = all(Http.Header.ACCEPT); if (acceptValues.size() == 1 && HUC_ACCEPT_DEFAULT.equals(acceptValues.get(0))) { result = HUC_ACCEPT_DEFAULT_TYPES; } else { result = LazyList.create(acceptValues.stream() .flatMap(h -> Utils.tokenize(',', "\"", false, h).stream()) .map(String::trim) .map(s -> LazyValue.create(() -> MediaType.parse(s))) .collect(Collectors.toList())); } result = Collections.unmodifiableList(result); this.acceptedtypesCache = result; } return result; } }
HashRequestHeaders extends ReadOnlyParameters implements RequestHeaders { @Override public List<MediaType> acceptedTypes() { List<MediaType> result = this.acceptedtypesCache; if (result == null) { List<String> acceptValues = all(Http.Header.ACCEPT); if (acceptValues.size() == 1 && HUC_ACCEPT_DEFAULT.equals(acceptValues.get(0))) { result = HUC_ACCEPT_DEFAULT_TYPES; } else { result = LazyList.create(acceptValues.stream() .flatMap(h -> Utils.tokenize(',', "\"", false, h).stream()) .map(String::trim) .map(s -> LazyValue.create(() -> MediaType.parse(s))) .collect(Collectors.toList())); } result = Collections.unmodifiableList(result); this.acceptedtypesCache = result; } return result; } HashRequestHeaders();   HashRequestHeaders(Map<String, List<String>> initialContent); }
HashRequestHeaders extends ReadOnlyParameters implements RequestHeaders { @Override public List<MediaType> acceptedTypes() { List<MediaType> result = this.acceptedtypesCache; if (result == null) { List<String> acceptValues = all(Http.Header.ACCEPT); if (acceptValues.size() == 1 && HUC_ACCEPT_DEFAULT.equals(acceptValues.get(0))) { result = HUC_ACCEPT_DEFAULT_TYPES; } else { result = LazyList.create(acceptValues.stream() .flatMap(h -> Utils.tokenize(',', "\"", false, h).stream()) .map(String::trim) .map(s -> LazyValue.create(() -> MediaType.parse(s))) .collect(Collectors.toList())); } result = Collections.unmodifiableList(result); this.acceptedtypesCache = result; } return result; } HashRequestHeaders();   HashRequestHeaders(Map<String, List<String>> initialContent); @Override Optional<MediaType> contentType(); @Override OptionalLong contentLength(); @Override Parameters cookies(); @Override List<MediaType> acceptedTypes(); @Override boolean isAccepted(MediaType mediaType); @Override Optional<MediaType> bestAccepted(MediaType... mediaTypes); @Override Optional<ZonedDateTime> acceptDatetime(); @Override Optional<ZonedDateTime> date(); @Override Optional<ZonedDateTime> ifModifiedSince(); @Override Optional<ZonedDateTime> ifUnmodifiedSince(); @Override Optional<URI> referer(); }
HashRequestHeaders extends ReadOnlyParameters implements RequestHeaders { @Override public List<MediaType> acceptedTypes() { List<MediaType> result = this.acceptedtypesCache; if (result == null) { List<String> acceptValues = all(Http.Header.ACCEPT); if (acceptValues.size() == 1 && HUC_ACCEPT_DEFAULT.equals(acceptValues.get(0))) { result = HUC_ACCEPT_DEFAULT_TYPES; } else { result = LazyList.create(acceptValues.stream() .flatMap(h -> Utils.tokenize(',', "\"", false, h).stream()) .map(String::trim) .map(s -> LazyValue.create(() -> MediaType.parse(s))) .collect(Collectors.toList())); } result = Collections.unmodifiableList(result); this.acceptedtypesCache = result; } return result; } HashRequestHeaders();   HashRequestHeaders(Map<String, List<String>> initialContent); @Override Optional<MediaType> contentType(); @Override OptionalLong contentLength(); @Override Parameters cookies(); @Override List<MediaType> acceptedTypes(); @Override boolean isAccepted(MediaType mediaType); @Override Optional<MediaType> bestAccepted(MediaType... mediaTypes); @Override Optional<ZonedDateTime> acceptDatetime(); @Override Optional<ZonedDateTime> date(); @Override Optional<ZonedDateTime> ifModifiedSince(); @Override Optional<ZonedDateTime> ifUnmodifiedSince(); @Override Optional<URI> referer();  }