LocalRequest implements org.zalando.logbook.HttpRequest { @Override public HttpHeaders getHeaders() { HttpHeaders headers = HttpHeaders.empty(); final Set<Entry<String, List<String>>> entries = Stream.of(request.getAllHeaders()) .collect(groupingBy( Header::getName, mapping(Header::getValue, toList()))) .entrySet(); for (final Entry<String, List<String>> entry : entries) { final String name = entry.getKey(); final List<String> values = entry.getValue(); headers = headers.update(name, values); } return headers; } LocalRequest(final HttpRequest request); @Override Origin getOrigin(); @Override String getProtocolVersion(); @Override String getRemote(); @Override String getMethod(); @Override String getScheme(); @Override String getHost(); @Override Optional<Integer> getPort(); @Override String getPath(); @Override String getQuery(); @Override HttpHeaders getHeaders(); @Override String getContentType(); @Override Charset getCharset(); @Override org.zalando.logbook.HttpRequest withBody(); @Override org.zalando.logbook.HttpRequest withoutBody(); @Override byte[] getBody();  }
@Test void shouldReturnContentTypeHeader() { final HttpRequest delegate = get("/"); delegate.addHeader("Content-Type", "text/plain;"); final LocalRequest unit = unit(delegate); assertThat(unit.getHeaders(), aMapWithSize(1)); }
@Test void shouldHandleDuplicateHeaders() { final HttpRequest delegate = post("/"); delegate.addHeader("Content-Type", "text/plain;"); delegate.addHeader("Content-Type", "text/plain;"); final LocalRequest unit = unit(delegate); assertThat(unit.getHeaders(), aMapWithSize(1)); assertThat(unit.getHeaders().get("Content-Type"), hasSize(2)); }