ReadOnlyHttpHeaders extends HttpHeaders { @Override public List<String> getAll(String name) { if (isEmpty()) { return Collections.emptyList(); } final int nameHash = AsciiString.hashCode(name); List<String> values = new ArrayList<String>(4); for (int i = 0; i < nameValuePairs.length; i += 2) { CharSequence roName = nameValuePairs[i]; if (AsciiString.hashCode(roName) == nameHash && contentEqualsIgnoreCase(roName, name)) { values.add(nameValuePairs[i + 1].toString()); } } return values; } ReadOnlyHttpHeaders(boolean validateHeaders, CharSequence... nameValuePairs); @Override String get(String name); @Override Integer getInt(CharSequence name); @Override int getInt(CharSequence name, int defaultValue); @Override Short getShort(CharSequence name); @Override short getShort(CharSequence name, short defaultValue); @Override Long getTimeMillis(CharSequence name); @Override long getTimeMillis(CharSequence name, long defaultValue); @Override List<String> getAll(String name); @Override List<Map.Entry<String, String>> entries(); @Override boolean contains(String name); @Override boolean contains(String name, String value, boolean ignoreCase); @Override boolean containsValue(CharSequence name, CharSequence value, boolean ignoreCase); @Override Iterator<String> valueStringIterator(CharSequence name); @Override Iterator<CharSequence> valueCharSequenceIterator(CharSequence name); @Override Iterator<Map.Entry<String, String>> iterator(); @Override Iterator<Map.Entry<CharSequence, CharSequence>> iteratorCharSequence(); @Override boolean isEmpty(); @Override int size(); @Override Set<String> names(); @Override HttpHeaders add(String name, Object value); @Override HttpHeaders add(String name, Iterable<?> values); @Override HttpHeaders addInt(CharSequence name, int value); @Override HttpHeaders addShort(CharSequence name, short value); @Override HttpHeaders set(String name, Object value); @Override HttpHeaders set(String name, Iterable<?> values); @Override HttpHeaders setInt(CharSequence name, int value); @Override HttpHeaders setShort(CharSequence name, short value); @Override HttpHeaders remove(String name); @Override HttpHeaders clear();  }
@Test public void getAll() { ReadOnlyHttpHeaders headers = new ReadOnlyHttpHeaders(false, ACCEPT, APPLICATION_JSON, CONTENT_LENGTH, ZERO, ACCEPT, APPLICATION_OCTET_STREAM); assertFalse(headers.isEmpty()); assertEquals(3, headers.size()); List<String> names = headers.getAll(ACCEPT); assertEquals(2, names.size()); assertTrue(APPLICATION_JSON.contentEqualsIgnoreCase(names.get(0))); assertTrue(APPLICATION_OCTET_STREAM.contentEqualsIgnoreCase(names.get(1))); }