@Test public void hucDefaultAccept(){ try { HashRequestHeaders hs = withHeader(Http.Header.ACCEPT, HashRequestHeaders.HUC_ACCEPT_DEFAULT); assertThat(hs.acceptedTypes().get(0), is(MediaType.TEXT_HTML)); assertThat(hs.acceptedTypes().get(1), is(createMt("image", "gif"))); assertThat(hs.acceptedTypes().get(2), is(createMt("image", "jpeg"))); assertThat(hs.acceptedTypes().get(3), is(createMt("*", "*", Map.of("q", ".2")))); } catch(IllegalStateException ex){ Assertions.fail(ex.getMessage(), ex); } }
@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();  }