private InterfaceHttpData findMultipartDisposition() {
        int readerIndex = undecodedChunk.readerIndex();
        if (currentStatus == MultiPartStatus.DISPOSITION) {
            currentFieldAttributes = new TreeMap<CharSequence, Attribute>(CaseIgnoringComparator.INSTANCE);
        }
        // read many lines until empty line with newline found! Store all data
        while (!skipOneLine()) {
            String newline;
            try {
                skipControlCharacters(undecodedChunk);
                newline = readLine(undecodedChunk, charset);
            } catch (NotEnoughDataDecoderException ignored) {
                undecodedChunk.readerIndex(readerIndex);
                return null;
            }
            String[] contents = splitMultipartHeader(newline);
            if (HttpHeaderNames.CONTENT_DISPOSITION.contentEqualsIgnoreCase(contents[0])) {
                boolean checkSecondArg;
                if (currentStatus == MultiPartStatus.DISPOSITION) {
                    checkSecondArg = HttpHeaderValues.FORM_DATA.contentEqualsIgnoreCase(contents[1]);
                } else {
                    checkSecondArg = HttpHeaderValues.ATTACHMENT.contentEqualsIgnoreCase(contents[1])
                            || HttpHeaderValues.FILE.contentEqualsIgnoreCase(contents[1]);
                }
                if (checkSecondArg) {
                    // read next values and store them in the map as Attribute
                    for (int i = 2; i < contents.length; i++) {
                        String[] values = contents[i].split("=", 2);
                        Attribute attribute;
                        try {
                            attribute = getContentDispositionAttribute(values);
                        } catch (NullPointerException e) {
                            throw new ErrorDataDecoderException(e);
                        } catch (IllegalArgumentException e) {
                            throw new ErrorDataDecoderException(e);
                        }
                        currentFieldAttributes.put(attribute.getName(), attribute);
                    }
                }
            } else if (HttpHeaderNames.CONTENT_TRANSFER_ENCODING.contentEqualsIgnoreCase(contents[0])) {
                Attribute attribute;
                try {
                    attribute = factory.createAttribute(request, HttpHeaderNames.CONTENT_TRANSFER_ENCODING.toString(),
                            cleanString(contents[1]));
                } catch (NullPointerException e) {
                    throw new ErrorDataDecoderException(e);
                } catch (IllegalArgumentException e) {
                    throw new ErrorDataDecoderException(e);
                }

                currentFieldAttributes.put(HttpHeaderNames.CONTENT_TRANSFER_ENCODING, attribute);
            } else if (HttpHeaderNames.CONTENT_LENGTH.contentEqualsIgnoreCase(contents[0])) {
                Attribute attribute;
                try {
                    attribute = factory.createAttribute(request, HttpHeaderNames.CONTENT_LENGTH.toString(),
                            cleanString(contents[1]));
                } catch (NullPointerException e) {
                    throw new ErrorDataDecoderException(e);
                } catch (IllegalArgumentException e) {
                    throw new ErrorDataDecoderException(e);
                }

                currentFieldAttributes.put(HttpHeaderNames.CONTENT_LENGTH, attribute);
            } else if (HttpHeaderNames.CONTENT_TYPE.contentEqualsIgnoreCase(contents[0])) {
                // Take care of possible "multipart/mixed"
                if (HttpHeaderValues.MULTIPART_MIXED.contentEqualsIgnoreCase(contents[1])) {
                    if (currentStatus == MultiPartStatus.DISPOSITION) {
                        String values = StringUtil.substringAfter(contents[2], '=');
                        multipartMixedBoundary = "--" + values;
                        currentStatus = MultiPartStatus.MIXEDDELIMITER;
                        return decodeMultipart(MultiPartStatus.MIXEDDELIMITER);
                    } else {
                        throw new ErrorDataDecoderException("Mixed Multipart found in a previous Mixed Multipart");
                    }
                } else {
                    for (int i = 1; i < contents.length; i++) {
                        final String charsetHeader = HttpHeaderValues.CHARSET.toString();
                        if (contents[i].regionMatches(true, 0, charsetHeader, 0, charsetHeader.length())) {
                            String values = StringUtil.substringAfter(contents[i], '=');
                            Attribute attribute;
                            try {
                                attribute = factory.createAttribute(request, charsetHeader, cleanString(values));
                            } catch (NullPointerException e) {
                                throw new ErrorDataDecoderException(e);
                            } catch (IllegalArgumentException e) {
                                throw new ErrorDataDecoderException(e);
                            }
                            currentFieldAttributes.put(HttpHeaderValues.CHARSET, attribute);
                        } else {
                            Attribute attribute;
                            try {
                                attribute = factory.createAttribute(request,
                                        cleanString(contents[0]), contents[i]);
                            } catch (NullPointerException e) {
                                throw new ErrorDataDecoderException(e);
                            } catch (IllegalArgumentException e) {
                                throw new ErrorDataDecoderException(e);
                            }
                            currentFieldAttributes.put(attribute.getName(), attribute);
                        }
                    }
                }
            } else {
                throw new ErrorDataDecoderException("Unknown Params: " + newline);
            }
        }
        // Is it a FileUpload
        Attribute filenameAttribute = currentFieldAttributes.get(HttpHeaderValues.FILENAME);
        if (currentStatus == MultiPartStatus.DISPOSITION) {
            if (filenameAttribute != null) {
                // FileUpload
                currentStatus = MultiPartStatus.FILEUPLOAD;
                // do not change the buffer position
                return decodeMultipart(MultiPartStatus.FILEUPLOAD);
            } else {
                // Field
                currentStatus = MultiPartStatus.FIELD;
                // do not change the buffer position
                return decodeMultipart(MultiPartStatus.FIELD);
            }
        } else {
            if (filenameAttribute != null) {
                // FileUpload
                currentStatus = MultiPartStatus.MIXEDFILEUPLOAD;
                // do not change the buffer position
                return decodeMultipart(MultiPartStatus.MIXEDFILEUPLOAD);
            } else {
                // Field is not supported in MIXED mode
                throw new ErrorDataDecoderException("Filename not found");
            }
        }
    }
private InterfaceHttpData findMultipartDisposition ( ) { int readerIndex = undecodedChunk . readerIndex ( ) ; if ( currentStatus == MultiPartStatus . DISPOSITION ) { currentFieldAttributes = new TreeMap < CharSequence , Attribute > ( CaseIgnoringComparator . INSTANCE ) ; } while ( ! skipOneLine ( ) ) { String newline ; try { skipControlCharacters ( undecodedChunk ) ; newline = readLine ( undecodedChunk , charset ) ; } catch ( NotEnoughDataDecoderException ignored ) { undecodedChunk . readerIndex ( readerIndex ) ; return null ; } String [ ] contents = splitMultipartHeader ( newline ) ; if ( HttpHeaderNames . CONTENT_DISPOSITION . contentEqualsIgnoreCase ( contents [ 0 ] ) ) { boolean checkSecondArg ; if ( currentStatus == MultiPartStatus . DISPOSITION ) { checkSecondArg = HttpHeaderValues . FORM_DATA . contentEqualsIgnoreCase ( contents [ 1 ] ) ; } else { checkSecondArg = HttpHeaderValues . ATTACHMENT . contentEqualsIgnoreCase ( contents [ 1 ] ) || HttpHeaderValues . FILE . contentEqualsIgnoreCase ( contents [ 1 ] ) ; } if ( checkSecondArg ) { for ( int i = 2 ; i < contents . length ; i ++ ) { String [ ] values = contents [ i ] . split ( "=" , 2 ) ; Attribute attribute ; try { attribute = getContentDispositionAttribute ( values ) ; } catch ( NullPointerException e ) { throw new ErrorDataDecoderException ( e ) ; } catch ( IllegalArgumentException e ) { throw new ErrorDataDecoderException ( e ) ; } currentFieldAttributes . put ( attribute . getName ( ) , attribute ) ; } } } else if ( HttpHeaderNames . CONTENT_TRANSFER_ENCODING . contentEqualsIgnoreCase ( contents [ 0 ] ) ) { Attribute attribute ; try { attribute = factory . createAttribute ( request , HttpHeaderNames . CONTENT_TRANSFER_ENCODING . toString ( ) , cleanString ( contents [ 1 ] ) ) ; } catch ( NullPointerException e ) { throw new ErrorDataDecoderException ( e ) ; } catch ( IllegalArgumentException e ) { throw new ErrorDataDecoderException ( e ) ; } currentFieldAttributes . put ( HttpHeaderNames . CONTENT_TRANSFER_ENCODING , attribute ) ; } else if ( HttpHeaderNames . CONTENT_LENGTH . contentEqualsIgnoreCase ( contents [ 0 ] ) ) { Attribute attribute ; try { attribute = factory . createAttribute ( request , HttpHeaderNames . CONTENT_LENGTH . toString ( ) , cleanString ( contents [ 1 ] ) ) ; } catch ( NullPointerException e ) { throw new ErrorDataDecoderException ( e ) ; } catch ( IllegalArgumentException e ) { throw new ErrorDataDecoderException ( e ) ; } currentFieldAttributes . put ( HttpHeaderNames . CONTENT_LENGTH , attribute ) ; } else if ( HttpHeaderNames . CONTENT_TYPE . contentEqualsIgnoreCase ( contents [ 0 ] ) ) { if ( HttpHeaderValues . MULTIPART_MIXED . contentEqualsIgnoreCase ( contents [ 1 ] ) ) { if ( currentStatus == MultiPartStatus . DISPOSITION ) { String values = StringUtil . substringAfter ( contents [ 2 ] , '=' ) ; multipartMixedBoundary = "--" + values ; currentStatus = MultiPartStatus . MIXEDDELIMITER ; return decodeMultipart ( MultiPartStatus . MIXEDDELIMITER ) ; } else { throw new ErrorDataDecoderException ( "Mixed Multipart found in a previous Mixed Multipart" ) ; } } else { for ( int i = 1 ; i < contents . length ; i ++ ) { final String charsetHeader = HttpHeaderValues . CHARSET . toString ( ) ; if ( contents [ i ] . regionMatches ( true , 0 , charsetHeader , 0 , charsetHeader . length ( ) ) ) { String values = StringUtil . substringAfter ( contents [ i ] , '=' ) ; Attribute attribute ; try { attribute = factory . createAttribute ( request , charsetHeader , cleanString ( values ) ) ; } catch ( NullPointerException e ) { throw new ErrorDataDecoderException ( e ) ; } catch ( IllegalArgumentException e ) { throw new ErrorDataDecoderException ( e ) ; } currentFieldAttributes . put ( HttpHeaderValues . CHARSET , attribute ) ; } else { Attribute attribute ; try { attribute = factory . createAttribute ( request , cleanString ( contents [ 0 ] ) , contents [ i ] ) ; } catch ( NullPointerException e ) { throw new ErrorDataDecoderException ( e ) ; } catch ( IllegalArgumentException e ) { throw new ErrorDataDecoderException ( e ) ; } currentFieldAttributes . put ( attribute . getName ( ) , attribute ) ; } } } } else { throw new ErrorDataDecoderException ( "Unknown Params: " + newline ) ; } } Attribute filenameAttribute = currentFieldAttributes . get ( HttpHeaderValues . FILENAME ) ; if ( currentStatus == MultiPartStatus . DISPOSITION ) { if ( filenameAttribute != null ) { currentStatus = MultiPartStatus . FILEUPLOAD ; return decodeMultipart ( MultiPartStatus . FILEUPLOAD ) ; } else { currentStatus = MultiPartStatus . FIELD ; return decodeMultipart ( MultiPartStatus . FIELD ) ; } } else { if ( filenameAttribute != null ) { currentStatus = MultiPartStatus . MIXEDFILEUPLOAD ; return decodeMultipart ( MultiPartStatus . MIXEDFILEUPLOAD ) ; } else { throw new ErrorDataDecoderException ( "Filename not found" ) ; } } }
Find the next Disposition

@return the next InterfaceHttpData if any
@throws ErrorDataDecoderException