Vary implements Serializable { public boolean matches(final HTTPRequest request) { if (varyHeaders.containsKey("ALL")) return false; Headers headers = request.getAllHeaders(); for (Map.Entry<String, String> varyEntry : varyHeaders.entrySet()) { if (request.getChallenge().isPresent() && varyEntry.getKey().equals(HeaderConstants.AUTHORIZATION)) { if (!request.getChallenge().get().getIdentifier().equals(varyEntry.getValue())) { return false; } } else { List<Header> requestHeaderValue = headers.getHeaders(varyEntry.getKey()); boolean valid = requestHeaderValue.isEmpty() ? varyEntry.getValue() == null : headers.getFirstHeader(varyEntry.getKey()).get().getValue().equals(varyEntry.getValue()); if (!valid) { return false; } } } List<Preference> preferences = new ArrayList<>(); preferences.addAll(headers.getAccept()); preferences.addAll(headers.getAcceptCharset()); preferences.addAll(headers.getAcceptLanguage()); return !(varyHeaders.isEmpty() && !preferences.isEmpty()); } Vary();  Vary(final Map<String, String> headers);  Vary(Headers headers); int size(); boolean isEmpty(); boolean matches(final HTTPRequest request); @Override String toString(); Map<String, String> getVaryHeaders(); static Vary parse(String value); boolean equals(final Object o); int hashCode(); static final Vary ALL; }
@Test public void All() { Vary STAR = Vary.ALL; HTTPRequest baseRequest = new HTTPRequest(URI.create("http: assertFalse("STAR matched request", STAR.matches(baseRequest)); assertFalse("STAR matched request", STAR.matches(baseRequest.addHeader("Accept", "application/xml"))); }