Java 类io.netty.handler.codec.http.multipart.HttpPostRequestDecoder.EndOfDataDecoderException 实例源码

项目:zbus    文件:MessageCodec.java   
private void handleUploadMessage(HttpMessage httpMsg, Message uploadMessage) throws IOException{
    if (httpMsg instanceof HttpContent) { 
           HttpContent chunk = (HttpContent) httpMsg;
           decoder.offer(chunk); 
           try {
               while (decoder.hasNext()) {
                   InterfaceHttpData data = decoder.next();
                   if (data != null) {
                       try { 
                        handleUploadFile(data, uploadMessage);
                       } finally {
                           data.release();
                       }
                   }
               }
           } catch (EndOfDataDecoderException e1) { 
            //ignore
           }

           if (chunk instanceof LastHttpContent) {  
            resetUpload();
           }
       }
}
项目:netty4.0.27Learn    文件:HttpUploadServerHandler.java   
/**
 * Example of reading request by chunk and getting values from chunk to chunk
 */
private void readHttpDataChunkByChunk() {
    try {
        while (decoder.hasNext()) {
            InterfaceHttpData data = decoder.next();
            if (data != null) {
                try {
                    // new value
                    writeHttpData(data);
                } finally {
                    data.release();
                }
            }
        }
    } catch (EndOfDataDecoderException e1) {
        // end
        responseContent.append("\r\n\r\nEND OF CONTENT CHUNK BY CHUNK\r\n\r\n");
    }
}
项目:netty4study    文件:HttpUploadServerHandler.java   
/**
 * Example of reading request by chunk and getting values from chunk to chunk
 */
private void readHttpDataChunkByChunk() {
    try {
        while (decoder.hasNext()) {
            InterfaceHttpData data = decoder.next();
            if (data != null) {
                try {
                    // new value
                    writeHttpData(data);
                } finally {
                    data.release();
                }
            }
        }
    } catch (EndOfDataDecoderException e1) {
        // end
        responseContent.append("\r\n\r\nEND OF CONTENT CHUNK BY CHUNK\r\n\r\n");
    }
}
项目:distributeTemplate    文件:HttpUploadServerHandler.java   
private void readHttpDataChunkByChunk() {
    int chunk=0;
    String checksum="";
    int sum=0;
    try {
        while (decoder.hasNext()) {
            InterfaceHttpData data = decoder.next();
            if (data != null) {
                try {

                    writeHttpData(data,chunk,checksum,sum);
                } finally {
                    data.release();
                }
            }
        }
    } catch (EndOfDataDecoderException e1) {
          return;
    } 
}
项目:netty-netty-5.0.0.Alpha1    文件:HttpUploadServerHandler.java   
/**
 * Example of reading request by chunk and getting values from chunk to chunk
 */
private void readHttpDataChunkByChunk() {
    try {
        while (decoder.hasNext()) {
            InterfaceHttpData data = decoder.next();
            if (data != null) {
                try {
                    // new value
                    writeHttpData(data);
                } finally {
                    data.release();
                }
            }
        }
    } catch (EndOfDataDecoderException e1) {
        // end
        responseContent.append("\r\n\r\nEND OF CONTENT CHUNK BY CHUNK\r\n\r\n");
    }
}
项目:netty4.0.27Learn    文件:HttpPostStandardRequestDecoder.java   
/**
 * True if at current getStatus, there is an available decoded
 * InterfaceHttpData from the Body.
 *
 * This getMethod works for chunked and not chunked request.
 *
 * @return True if at current getStatus, there is a decoded InterfaceHttpData
 * @throws EndOfDataDecoderException
 *             No more data will be available
 */
@Override
public boolean hasNext() {
    checkDestroyed();

    if (currentStatus == MultiPartStatus.EPILOGUE) {
        // OK except if end of list
        if (bodyListHttpDataRank >= bodyListHttpData.size()) {
            throw new EndOfDataDecoderException();
        }
    }
    return !bodyListHttpData.isEmpty() && bodyListHttpDataRank < bodyListHttpData.size();
}
项目:netty4.0.27Learn    文件:HttpPostMultipartRequestDecoder.java   
/**
 * True if at current getStatus, there is an available decoded
 * InterfaceHttpData from the Body.
 *
 * This getMethod works for chunked and not chunked request.
 *
 * @return True if at current getStatus, there is a decoded InterfaceHttpData
 * @throws EndOfDataDecoderException
 *             No more data will be available
 */
@Override
public boolean hasNext() {
    checkDestroyed();

    if (currentStatus == MultiPartStatus.EPILOGUE) {
        // OK except if end of list
        if (bodyListHttpDataRank >= bodyListHttpData.size()) {
            throw new EndOfDataDecoderException();
        }
    }
    return !bodyListHttpData.isEmpty() && bodyListHttpDataRank < bodyListHttpData.size();
}
项目:blynk-server    文件:UploadHandler.java   
private String finishUpload() throws Exception {
    String pathTo = null;
    try {
        while (decoder.hasNext()) {
            InterfaceHttpData data = decoder.next();
            if (data != null) {
                if (data instanceof DiskFileUpload) {
                    DiskFileUpload diskFileUpload = (DiskFileUpload) data;
                    Path tmpFile = diskFileUpload.getFile().toPath();
                    String uploadedFilename = diskFileUpload.getFilename();
                    String extension = "";
                    if (uploadedFilename.contains(".")) {
                        extension = uploadedFilename.substring(uploadedFilename.lastIndexOf("."),
                                uploadedFilename.length());
                    }
                    String finalName = tmpFile.getFileName().toString() + extension;

                    //this is just to make it work on team city.
                    Path staticPath = Paths.get(staticFolderPath, uploadFolder);
                    if (!Files.exists(staticPath)) {
                        Files.createDirectories(staticPath);
                    }

                    Files.move(tmpFile, Paths.get(staticFolderPath, uploadFolder, finalName),
                            StandardCopyOption.REPLACE_EXISTING);
                    pathTo =  uploadFolder + finalName;
                }
                data.release();
            }
        }
    } catch (EndOfDataDecoderException endOfData) {
        //ignore. that's fine.
    } finally {
        // destroy the decoder to release all resources
        decoder.destroy();
        decoder = null;
    }

    return pathTo;
}
项目:netty-netty-5.0.0.Alpha1    文件:HttpPostStandardRequestDecoder.java   
/**
 * True if at current getStatus, there is an available decoded
 * InterfaceHttpData from the Body.
 *
 * This getMethod works for chunked and not chunked request.
 *
 * @return True if at current getStatus, there is a decoded InterfaceHttpData
 * @throws EndOfDataDecoderException
 *             No more data will be available
 */
@Override
public boolean hasNext() {
    checkDestroyed();

    if (currentStatus == MultiPartStatus.EPILOGUE) {
        // OK except if end of list
        if (bodyListHttpDataRank >= bodyListHttpData.size()) {
            throw new EndOfDataDecoderException();
        }
    }
    return !bodyListHttpData.isEmpty() && bodyListHttpDataRank < bodyListHttpData.size();
}
项目:netty-netty-5.0.0.Alpha1    文件:HttpPostMultipartRequestDecoder.java   
/**
 * True if at current getStatus, there is an available decoded
 * InterfaceHttpData from the Body.
 *
 * This getMethod works for chunked and not chunked request.
 *
 * @return True if at current getStatus, there is a decoded InterfaceHttpData
 * @throws EndOfDataDecoderException
 *             No more data will be available
 */
@Override
public boolean hasNext() {
    checkDestroyed();

    if (currentStatus == MultiPartStatus.EPILOGUE) {
        // OK except if end of list
        if (bodyListHttpDataRank >= bodyListHttpData.size()) {
            throw new EndOfDataDecoderException();
        }
    }
    return !bodyListHttpData.isEmpty() && bodyListHttpDataRank < bodyListHttpData.size();
}