HttpHeadersBase extends StringMultimap</* IN_NAME */ CharSequence, /* NAME */ AsciiString> implements HttpHeaderGetters { @Override public final String toString() { if (size == 0) { return endOfStream ? "[EOS]" : "[]"; } final StringBuilder sb = new StringBuilder(7 + size * 20); if (endOfStream) { sb.append("[EOS, "); } else { sb.append('['); } for (Map.Entry<AsciiString, String> e : this) { sb.append(e.getKey()).append('=').append(e.getValue()).append(", "); } final int length = sb.length(); sb.setCharAt(length - 2, ']'); return sb.substring(0, length - 1); } HttpHeadersBase(int sizeHint);   HttpHeadersBase(HttpHeadersBase parent, boolean shallowCopy);   HttpHeadersBase(HttpHeaderGetters parent); @Nullable @Override MediaType contentType(); @Override final boolean isEndOfStream(); @Override final int hashCode(); @Override boolean equals(@Nullable Object o); @Override final String toString();  }
@Test void testToString() { HttpHeadersBase headers = newEmptyHeaders(); headers.add("name1", "value1"); headers.add("name1", "value2"); headers.add("name2", "value3"); assertThat(headers.toString()).isEqualTo("[name1=value1, name1=value2, name2=value3]"); headers = newEmptyHeaders(); headers.add("name1", "value1"); headers.add("name2", "value2"); headers.add("name3", "value3"); assertThat(headers.toString()).isEqualTo("[name1=value1, name2=value2, name3=value3]"); headers = newEmptyHeaders(); headers.add("name1", "value1"); assertThat(headers.toString()).isEqualTo("[name1=value1]"); headers = newEmptyHeaders(); headers.endOfStream(true); headers.add("name1", "value1"); assertThat(headers.toString()).isEqualTo("[EOS, name1=value1]"); headers = newEmptyHeaders(); assertThat(headers.toString()).isEqualTo("[]"); headers = newEmptyHeaders(); headers.endOfStream(true); assertThat(headers.toString()).isEqualTo("[EOS]"); }