Package com.facebook.presto.jdbc.internal.netty.handler.codec.http

Examples of com.facebook.presto.jdbc.internal.netty.handler.codec.http.DefaultHttpChunk


        if (currentBuffer.readableBytes() < HttpPostBodyUtil.chunkSize) {
            currentData = null;
            return null;
        }
        buffer = fillChannelBuffer();
        return new DefaultHttpChunk(buffer);
    }
View Full Code Here


                //continue
                size -= buffer.readableBytes() + 1;
            }
            if (currentBuffer.readableBytes() >= HttpPostBodyUtil.chunkSize) {
                buffer = fillChannelBuffer();
                return new DefaultHttpChunk(buffer);
            }
        }
        try {
            buffer = ((HttpData) currentData).getChunk(size);
        } catch (IOException e) {
            throw new ErrorDataEncoderException(e);
        }
        ChannelBuffer delimiter = null;
        if (buffer.readableBytes() < size) {
            // delimiter
            isKey = true;
            delimiter = iterator.hasNext() ?
                    ChannelBuffers.wrappedBuffer("&".getBytes()) :
                        null;
        }
        if (buffer.capacity() == 0) {
            // end for current InterfaceHttpData, need potentially more data
            currentData = null;
            if (currentBuffer == null) {
                currentBuffer = delimiter;
            } else {
                if (delimiter != null) {
                    currentBuffer = ChannelBuffers.wrappedBuffer(currentBuffer,
                        delimiter);
                }
            }
            if (currentBuffer.readableBytes() >= HttpPostBodyUtil.chunkSize) {
                buffer = fillChannelBuffer();
                return new DefaultHttpChunk(buffer);
            }
            return null;
        }
        if (currentBuffer == null) {
            if (delimiter != null) {
                currentBuffer = ChannelBuffers.wrappedBuffer(buffer,
                    delimiter);
            } else {
                currentBuffer = buffer;
            }
        } else {
            if (delimiter != null) {
                currentBuffer = ChannelBuffers.wrappedBuffer(currentBuffer,
                    buffer, delimiter);
            } else {
                currentBuffer = ChannelBuffers.wrappedBuffer(currentBuffer,
                        buffer);
            }
        }
        if (currentBuffer.readableBytes() < HttpPostBodyUtil.chunkSize) {
            // end for current InterfaceHttpData, need more data
            currentData = null;
            isKey = true;
            return null;
        }
        buffer = fillChannelBuffer();
        // size = 0
        return new DefaultHttpChunk(buffer);
    }
View Full Code Here

     * @throws ErrorDataEncoderException if the encoding is in error
     */
    public HttpChunk nextChunk() throws ErrorDataEncoderException {
        if (isLastChunk) {
            isLastChunkSent = true;
            return new DefaultHttpChunk(ChannelBuffers.EMPTY_BUFFER);
        }
        ChannelBuffer buffer;
        int size = HttpPostBodyUtil.chunkSize;
        // first test if previous buffer is not empty
        if (currentBuffer != null) {
            size -= currentBuffer.readableBytes();
        }
        if (size <= 0) {
            //NextChunk from buffer
            buffer = fillChannelBuffer();
            return new DefaultHttpChunk(buffer);
        }
        // size > 0
        if (currentData != null) {
            // continue to read data
            if (isMultipart) {
                HttpChunk chunk = encodeNextChunkMultipart(size);
                if (chunk != null) {
                    return chunk;
                }
            } else {
                HttpChunk chunk = encodeNextChunkUrlEncoded(size);
                if (chunk != null) {
                    //NextChunk Url from currentData
                    return chunk;
                }
            }
            size = HttpPostBodyUtil.chunkSize - currentBuffer.readableBytes();
        }
        if (! iterator.hasNext()) {
            isLastChunk = true;
            //NextChunk as last non empty from buffer
            buffer = currentBuffer;
            currentBuffer = null;
            return new DefaultHttpChunk(buffer);
        }
        while (size > 0 && iterator.hasNext()) {
            currentData = iterator.next();
            HttpChunk chunk;
            if (isMultipart) {
                chunk = encodeNextChunkMultipart(size);
            } else {
                chunk = encodeNextChunkUrlEncoded(size);
            }
            if (chunk == null) {
                // not enough
                size = HttpPostBodyUtil.chunkSize - currentBuffer.readableBytes();
                continue;
            }
            //NextChunk from data
            return chunk;
        }
        // end since no more data
        isLastChunk = true;
        if (currentBuffer == null) {
            isLastChunkSent = true;
            //LastChunk with no more data
            return new DefaultHttpChunk(ChannelBuffers.EMPTY_BUFFER);
        }
        //Previous LastChunk with no more data
        buffer = currentBuffer;
        currentBuffer = null;
        return new DefaultHttpChunk(buffer);
    }
View Full Code Here

        final ChannelFuture f;

        if (size == 0) {
            f = realChannel.write(ChannelBuffers.EMPTY_BUFFER);
        } else {
            f = realChannel.write(new DefaultHttpChunk(a));
        }

        f.addListener(new ChannelFutureListener() {
            public void operationComplete(ChannelFuture f) {
                if (f.isSuccess()) {
View Full Code Here

TOP

Related Classes of com.facebook.presto.jdbc.internal.netty.handler.codec.http.DefaultHttpChunk

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.