@Test
void testSplitHeaderParse() {

    ByteBuffer buffer = BufferUtils.toBuffer(
            "XXXXSPLIT / HTTP/1.0\r\n" +
                    "Host: localhost\r\n" +
                    "Header1: value1\r\n" +
                    "Header2:   value 2a  \r\n" +
                    "Header3: 3\r\n" +
                    "Header4:value4\r\n" +
                    "Server5: notServer\r\n" +
                    "\r\nZZZZ");
    buffer.position(2);
    buffer.limit(buffer.capacity() - 2);
    buffer = buffer.slice();
    for (int i = 0; i < buffer.capacity() - 4; i++) {
        HttpParser.RequestHandler handler = new Handler();
        HttpParser parser = new HttpParser(handler);
        buffer.position(2);
        buffer.limit(2 + i);
        if (!parser.parseNext(buffer)) {
            // consumed all
            assertEquals(0, buffer.remaining());
            // parse the rest
            buffer.limit(buffer.capacity() - 2);
            parser.parseNext(buffer);
        }
        assertEquals("SPLIT", methodOrVersion);
        assertEquals("/", uriOrStatus);
        assertEquals("HTTP/1.0", versionOrReason);
        assertEquals("Host", hdr[0]);
        assertEquals("localhost", val[0]);
        assertEquals("Header1", hdr[1]);
        assertEquals("value1", val[1]);
        assertEquals("Header2", hdr[2]);
        assertEquals("value 2a", val[2]);
        assertEquals("Header3", hdr[3]);
        assertEquals("3", val[3]);
        assertEquals("Header4", hdr[4]);
        assertEquals("value4", val[4]);
        assertEquals("Server5", hdr[5]);
        assertEquals("notServer", val[5]);
        assertEquals(5, headers);
    }
}