Search in sources :

Example 1 with Blob

use of org.jocean.netty.BlobRepo.Blob in project jocean-http by isdom.

the class AsBlob method onNext4Multipart.

private Observable<? extends Blob> onNext4Multipart(final HttpContent content) {
    try {
        _postDecoder.offer(content);
    } catch (ErrorDataDecoderException e) {
        LOG.warn("exception when postDecoder.offer, detail: {}", ExceptionUtils.exception2detail(e));
    }
    final List<Blob> blobs = new ArrayList<>();
    try {
        while (_postDecoder.hasNext()) {
            final InterfaceHttpData data = _postDecoder.next();
            if (data != null) {
                try {
                    final Blob blob = this._holder.hold(processHttpData(data));
                    if (null != blob) {
                        blobs.add(blob);
                        LOG.info("onNext4Multipart: add Blob {}", blob);
                    }
                } finally {
                    data.release();
                }
            }
        }
    } catch (EndOfDataDecoderException e) {
        LOG.warn("exception when postDecoder.hasNext, detail: {}", ExceptionUtils.exception2detail(e));
    }
    return blobs.isEmpty() ? Observable.<Blob>empty() : Observable.from(blobs);
}
Also used : Blob(org.jocean.netty.BlobRepo.Blob) EndOfDataDecoderException(io.netty.handler.codec.http.multipart.HttpPostRequestDecoder.EndOfDataDecoderException) InterfaceHttpData(io.netty.handler.codec.http.multipart.InterfaceHttpData) ArrayList(java.util.ArrayList) ErrorDataDecoderException(io.netty.handler.codec.http.multipart.HttpPostRequestDecoder.ErrorDataDecoderException)

Aggregations

EndOfDataDecoderException (io.netty.handler.codec.http.multipart.HttpPostRequestDecoder.EndOfDataDecoderException)1 ErrorDataDecoderException (io.netty.handler.codec.http.multipart.HttpPostRequestDecoder.ErrorDataDecoderException)1 InterfaceHttpData (io.netty.handler.codec.http.multipart.InterfaceHttpData)1 ArrayList (java.util.ArrayList)1 Blob (org.jocean.netty.BlobRepo.Blob)1