HttpHeaderUtil { public static <T extends MultiMap> T removeNonForwardHeaders( T headers ) { final String CONNECTION = HttpRequestHeader.CONNECTION.getName(); headers.getAll(CONNECTION).forEach(headers::remove); headers.remove(CONNECTION); return headers; }  static T removeNonForwardHeaders( T headers );  }
@Test public void removeNonForwardHeadersTest(TestContext testContext) { CaseInsensitiveHeaders headers = new CaseInsensitiveHeaders(); headers.add(CONNECTION, "one" ); headers.add(CONNECTION, "two" ); headers.add(CONNECTION, "three" ); headers.add("an-unrelated-one", "123"); headers.add("another-unrelated", "close"); headers.add("one", "stuff"); headers.add("three", "other stuff"); headers = HttpHeaderUtil.removeNonForwardHeaders(headers); testContext.assertTrue(headers.contains("an-unrelated-one")); testContext.assertTrue(headers.contains("another-unrelated")); testContext.assertFalse(headers.contains(CONNECTION)); testContext.assertFalse(headers.contains("one")); testContext.assertFalse(headers.contains("three")); testContext.assertEquals(2, headers.size()); }