### Question:
HeaderUtils { static void addRequestTransferEncodingIfNecessary(final StreamingHttpRequest request) { if (canAddRequestTransferEncoding(request)) { request.headers().add(TRANSFER_ENCODING, CHUNKED); } } private  HeaderUtils();   }### Answer:
@Test public void addTransferEncodingIfNecessaryNoHeaders() { assertTrue(httpRequest.headers().isEmpty()); addRequestTransferEncodingIfNecessary(httpRequest); assertOneTransferEncodingChunked(httpRequest.headers()); }
@Test public void addTransferEncodingIfNecessaryContentLength() { assertTrue(httpRequest.headers().isEmpty()); httpRequest.headers().add(CONTENT_LENGTH, "10"); assertEquals(1, httpRequest.headers().size()); addRequestTransferEncodingIfNecessary(httpRequest); assertEquals(1, httpRequest.headers().size()); assertFalse(isTransferEncodingChunked(httpRequest.headers())); assertEquals("10", httpRequest.headers().get(CONTENT_LENGTH)); }
@Test public void addTransferEncodingIfNecessaryTransferEncodingChunked() { assertTrue(httpRequest.headers().isEmpty()); httpRequest.headers().add(TRANSFER_ENCODING, CHUNKED); assertEquals(1, httpRequest.headers().size()); addRequestTransferEncodingIfNecessary(httpRequest); assertOneTransferEncodingChunked(httpRequest.headers()); }
@Test public void addTransferEncodingIfNecessaryTransferEncodingChunkedCapitalCase() { assertTrue(httpRequest.headers().isEmpty()); httpRequest.headers().add("Transfer-Encoding", "Chunked"); assertEquals(1, httpRequest.headers().size()); addRequestTransferEncodingIfNecessary(httpRequest); assertOneTransferEncodingChunked(httpRequest.headers()); }
@Test public void addTransferEncodingIfNecessaryTransferEncodingChunkedRandomCase() { assertTrue(httpRequest.headers().isEmpty()); httpRequest.headers().add(TRANSFER_ENCODING, "cHuNkEd"); assertEquals(1, httpRequest.headers().size()); addRequestTransferEncodingIfNecessary(httpRequest); assertOneTransferEncodingChunked(httpRequest.headers()); }