private ByteBuf readBody() {
        // matches boundary
        boundaryStart = match();
        final int length = in.readableBytes();

        if (boundaryStart == -1) {
            // No boundary is found
            if (boundaryLength + 1 < length) {
                // There may be an incomplete boundary at the end of the buffer.
                // Return the remaining data minus the boundary length
                // so that it can be processed next iteration.
                // e.g. |---body---|--bound|

                final int bodyLength = length - (boundaryLength + 1);
                return in.readBytes(bodyLength);
            }
            // remaining data can be a complete boundary, force it to be
            // processed during next iteration
            return NEED_MORE;
        }

        // Found boundary.
        // Is it at the start of a line ?
        int bodyLength = boundaryStart;
        if (startOfLine && bodyLength == 0) {
            // an empty body, nothing to do
            // e.g. ||--boundary|
        } else {
            final byte last = in.getByte(boundaryStart - 1);
            // Remove CRLF from bodyLength
            if (boundaryStart > 0 && (last == '\n' || last == '\r')) {
                // e.g. |---body---\n|--boundary|
                --bodyLength;
                if (last == '\n' && boundaryStart > 1 && in.getByte(boundaryStart - 2) == '\r') {
                    // e.g. |---body---\r\n|--boundary|
                    --bodyLength;
                }
            } else {
                // Boundary is not at beginning of a line. A boundary string can be in a body.
                // e.g. |---body---boundary---|
                return in.readBytes(bodyLength + 1);
            }
        }

        int boundaryEnd = boundaryStart + boundaryLength;
        // check if this is a "closing" boundary
        // e.g. |---body---\n|--boundary--|
        if (boundaryEnd + 1 < length && in.getByte(boundaryEnd) == '-' && in.getByte(boundaryEnd + 1) == '-') {

            state = State.END_PART;
            done = true;
            final ByteBuf body = safeReadBytes(in, bodyLength);

            // Discard a closing boundary
            in.skipBytes(boundaryLength + 2);
            return body;
        }

        // Consider all the linear whitespace in boundary+whitespace+"\r\n"
        // e.g. |---body---\n|--boundary \t\t\r\n|
        for (int i = boundaryEnd; i < length; i++) {
            final byte current = in.getByte(i);
            if (current == ' ' || current == '\t') {
                boundaryEnd++;
            } else {
                break;
            }
        }

        if (boundaryEnd < length) {
            // Check boundary+whitespace+"\n"
            // e.g. |---body---\n|--boundary\n|
            final byte closingChar = in.getByte(boundaryEnd);
            if (closingChar == '\n') {
                state = State.END_PART;
                final ByteBuf body = safeReadBytes(in, bodyLength);

                // Skip boundary+whitespace+"\n"
                in.skipBytes(boundaryEnd + 1 - bodyLength);
                return body;
            }

            // Check for boundary+whitespace+"\r\n"
            // e.g. |---body---\n|--boundary--\r\n|
            if (boundaryEnd + 1 < length &&
                closingChar == '\r' &&
                in.getByte(boundaryEnd + 1) == '\n') {

                state = State.END_PART;
                final ByteBuf body = safeReadBytes(in, bodyLength);

                // Skip boundary+whitespace+"\r\n"
                in.skipBytes(boundaryEnd + 2 - bodyLength);
                return body;
            }
        }

        if (boundaryEnd + 1 < length) {
            // It is not a closing boundary, but there is no CRLF.
            // A boundary string is in a part data.
            return in.readBytes(bodyLength + 1);
        }

        // A boundary is found but it's not a "closing" boundary
        // return everything before that boundary as the "closing" characters
        // might be available next iteration
        final ByteBuf body = safeReadBytes(in, bodyLength);
        in.skipBytes(boundaryStart - bodyLength);
        return body;
    }
Reads the next part body content.
Returns {@link #NEED_MORE} if more data is required and no body content can be returned.
core/src/main/java/com/linecorp/armeria/common/multipart/MimeParser.java