Headers { public List<String> values(String name) { List<String> result = null; for (int i = 0, size = size(); i < size; i++) { if (name.equalsIgnoreCase(name(i))) { if (result == null) result = new ArrayList<>(2); result.add(value(i)); } } return result != null ? Collections.unmodifiableList(result) : Collections.<String>emptyList(); } private  Headers(Builder builder); private  Headers(String[] namesAndValues); String get(String name); Date getDate(String name); int size(); String name(int index); String value(int index); Set<String> names(); List<String> values(String name); Builder newBuilder(); @Override boolean equals(Object other); @Override int hashCode(); @Override String toString(); Map<String, List<String>> toMultimap(); Map<String, String> toMap(); static Headers of(String... namesAndValues); static Headers of(Map<String, String> headers); static Headers ofMMap(Map<String, List<String>> headers);  }
@Test public void addParsing() { Headers headers = new Headers.Builder() .add("foo: bar") .add(" foo: baz") .add("foo : bak") .add("ping: pong ") .add("kit:kat") .build(); assertEquals(Arrays.asList("bar", "baz", "bak"), headers.values("foo")); assertEquals(Arrays.asList("pong"), headers.values("ping")); assertEquals(Arrays.asList("kat"), headers.values("kit")); }