@Test
  public void testNegotiatesEncodingGzip() throws IOException {
    final InputStream stream = ClassLoader.getSystemResourceAsStream("webapps/static/test.css");
    assertNotNull(stream);
    final String sourceContent = readFully(stream);

    try (final CloseableHttpClient client = HttpClients.createMinimal()) {
      final HttpGet request = new HttpGet(new URL(baseUrl, "/static/test.css").toString());

      request.setHeader(HttpHeaders.ACCEPT_ENCODING, null);
      final long unencodedContentLength;
      try (final CloseableHttpResponse response = client.execute(request)) {
        final HttpEntity entity = response.getEntity();
        assertNotNull(entity);
        assertNull(entity.getContentEncoding());
        unencodedContentLength = entity.getContentLength();
        MatcherAssert.assertThat(unencodedContentLength, greaterThan(0L));
        final String unencodedEntityBody = readFully(entity.getContent());
        assertEquals(sourceContent, unencodedEntityBody);
      }

      request.setHeader(HttpHeaders.ACCEPT_ENCODING, "gzip");
      final long encodedContentLength;
      try (final CloseableHttpResponse response = client.execute(request)) {
        final HttpEntity entity = response.getEntity();
        assertNotNull(entity);
        assertNotNull(entity.getContentEncoding());
        assertEquals("gzip", entity.getContentEncoding().getValue());
        encodedContentLength = entity.getContentLength();
        MatcherAssert.assertThat(encodedContentLength, greaterThan(0L));
        final String encodedEntityBody = readFully(entity.getContent());
        // the encoding/decoding process, as implemented in this specific combination of dependency
        // versions, does not perfectly preserve trailing whitespace. thus, `trim()`.
        assertEquals(sourceContent.trim(), encodedEntityBody.trim());
      }
      MatcherAssert.assertThat(unencodedContentLength, greaterThan(encodedContentLength));
    }
  }
Test that verifies headers can be up to 64K long. The test adds a 63K header leaving 1K for
other headers. This is because the header buffer setting is for ALL headers, names and values
included.
hbase-http/src/test/java/org/apache/hadoop/hbase/http/TestHttpServer.java