code: private int findEndOfLine(final ByteBuf buffer) {
          int totalLength = buffer.readableBytes();
          int i = buffer.forEachByte(buffer.readerIndex() + offset, totalLength - offset, ByteProcessor.FIND_LF);
          if (i >= 0) {
              offset = 0;
              if (i > 0 && buffer.getByte(i - 1) == '\r') {
                  i--;
              }
          } else {
              offset = totalLength;
          }
          return i;
      }
docs: Returns the index in the buffer of the end of line found.
  Returns -1 if no end of line was found in the buffer.