private static boolean loadDataMultipartStandard ( ByteBuf undecodedChunk , String delimiter , HttpData httpData ) { final int startReaderIndex = undecodedChunk . readerIndex ( ) ; final int delimeterLength = delimiter . length ( ) ; int index = 0 ; int lastPosition = startReaderIndex ; byte prevByte = HttpConstants . LF ; boolean delimiterFound = false ; while ( undecodedChunk . isReadable ( ) ) { final byte nextByte = undecodedChunk . readByte ( ) ; // Check the delimiter if ( prevByte == HttpConstants . LF && nextByte == delimiter . codePointAt ( index ) ) { index ++ ; if ( delimeterLength == index ) { delimiterFound = true ; break ; } continue ; } lastPosition = undecodedChunk . readerIndex ( ) ; if ( nextByte == HttpConstants . LF ) { index = 0 ; lastPosition -= ( prevByte == HttpConstants . CR ) ? 2 : 1 ; } prevByte = nextByte ; } if ( prevByte == HttpConstants . CR ) { lastPosition -- ; } ByteBuf content = undecodedChunk . copy ( startReaderIndex , lastPosition - startReaderIndex ) ; try { httpData . addContent ( content , delimiterFound ) ; } catch ( IOException e ) { throw new ErrorDataDecoderException ( e ) ; } undecodedChunk . readerIndex ( lastPosition ) ; return delimiterFound ; }
Load the field value or file data from a Multipart request