HttpHeadersImpl implements HttpHeaders { @Override public int getLength() { String value = nettyHttpHeaders.get(HttpHeaders.CONTENT_LENGTH); if (value == null || value.isEmpty()) { return -1; } int length = Integer.parseInt(value); return length >= 0 ? length : -1; } HttpHeadersImpl(io.netty.handler.codec.http.HttpHeaders httpHeaders); @Override List<String> getRequestHeader(String name); @Override String getHeaderString(String name); @Override MultivaluedMap<String, String> getRequestHeaders(); @Override List<MediaType> getAcceptableMediaTypes(); @Override List<Locale> getAcceptableLanguages(); @Override MediaType getMediaType(); @Override Locale getLanguage(); @Override Map<String, Cookie> getCookies(); @Override Date getDate(); @Override int getLength();  }
@Test public void testGetLength() throws Exception { int length = httpHeaders1.getLength(); assertEquals(length, 1024); int length2 = httpHeaders2.getLength(); assertEquals(length2, -1); }