LocalRequest implements org.zalando.logbook.HttpRequest { @Override public Charset getCharset() { return Optional.of(request) .map(request -> request.getFirstHeader("Content-Type")) .map(Header::getValue) .map(ContentType::parse) .map(ContentType::getCharset) .orElse(UTF_8); } 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 shouldReturnContentTypesCharsetIfGiven() { final HttpRequest delegate = get("/"); delegate.addHeader("Content-Type", "text/plain;charset=ISO-8859-1"); final LocalRequest unit = unit(delegate); assertThat(unit.getCharset(), is(StandardCharsets.ISO_8859_1)); }
@Test void shouldReturnDefaultCharsetIfNoneGiven() { final LocalRequest unit = unit(get("/")); assertThat(unit.getCharset(), is(UTF_8)); }