private int findHeaderEnd(final byte[] buf, int rlen) {
        int splitbyte = 0;
        while (splitbyte + 1 < rlen) {

            // RFC2616
            if (buf[splitbyte] == '\r' && buf[splitbyte + 1] == '\n' && splitbyte + 3 < rlen && buf[splitbyte + 2] == '\r' && buf[splitbyte + 3] == '\n') {
                return splitbyte + 4;
            }

            // tolerance
            if (buf[splitbyte] == '\n' && buf[splitbyte + 1] == '\n') {
                return splitbyte + 2;
            }
            splitbyte++;
        }
        return 0;
    }
private int findHeaderEnd(final byte[] buf, int rlen) {
        int splitbyte = 0;
        while (splitbyte + 1 < rlen) {

            
            if (buf[splitbyte] == '\r' && buf[splitbyte + 1] == '\n' && splitbyte + 3 < rlen && buf[splitbyte + 2] == '\r' && buf[splitbyte + 3] == '\n') {
                return splitbyte + 4;
            }

            
            if (buf[splitbyte] == '\n' && buf[splitbyte + 1] == '\n') {
                return splitbyte + 2;
            }
            splitbyte++;
        }
        return 0;
    }
private int findHeaderEnd ( final byte [ ] buf , int rlen ) { int splitbyte = 0 ; while ( splitbyte + 1 < rlen ) { // RFC2616 if ( buf [ splitbyte ] == ' ' && buf [ splitbyte + 1 ] == ' ' && splitbyte + 3 < rlen && buf [ splitbyte + 2 ] == ' ' && buf [ splitbyte + 3 ] == ' ' ) { return splitbyte + 4 ; } // tolerance if ( buf [ splitbyte ] == ' ' && buf [ splitbyte + 1 ] == ' ' ) { return splitbyte + 2 ; } splitbyte ++ ; } return 0 ; }
Find byte index separating header from body. It must be the last byte of
the first two sequential new lines.
Find byte index separating header from body . It must be the last byte of the first two sequential new lines .