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

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