Top Description Fields Constructors Methods
io.netty.handler.codec.http2

public final Class Http2DataChunkedInput

extends Object
implements ChunkedInput<Http2DataFrame>
Class Inheritance
All Implemented Interfaces
io.netty.handler.stream.ChunkedInput
Imports
io.netty.buffer.ByteBuf, .ByteBufAllocator, io.netty.channel.ChannelHandlerContext, io.netty.handler.stream.ChunkedInput, io.netty.util.internal.ObjectUtil

A ChunkedInput that fetches data chunk by chunk for use with HTTP/2 Data Frames.

Each chunk from the input data will be wrapped within a Http2DataFrame. At the end of the input data, Http2DataFrame#isEndStream() will be set to true and will be written.


    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
        if (msg instanceof Http2HeadersFrame) {
            Http2HeadersFrame http2HeadersFrame = (Http2HeadersFrame) msg;

            Http2HeadersFrame response = new DefaultHttp2HeadersFrame(new DefaultHttp2Headers().status("200"));
            response.stream(http2HeadersFrame.stream());
            ctx.write(response);

            ChannelFuture sendFileFuture = ctx.writeAndFlush(new Http2DataChunkedInput(
                    new ChunkedFile(new File(("/home/meow/cats.mp4"))), http2HeadersFrame.stream()));
        }
    }

Field Summary

Modifier and TypeField and Description
private boolean
private final ChunkedInput<ByteBuf>
private final Http2FrameStream

Constructor Summary

AccessConstructor and Description
public
Http2DataChunkedInput(ChunkedInput<ByteBuf>
ChunkedInput containing data to write
input
,
Http2FrameStream
Http2FrameStream holding stream info
stream
)

Creates a new instance using the specified input.

Method Summary

Modifier and TypeMethod and Description
public void
close()

Implements io.netty.handler.stream.ChunkedInput.close.

Releases the resources associated with the input.
public boolean
isEndOfInput()

Implements io.netty.handler.stream.ChunkedInput.isEndOfInput.

Return true if and only if there is no data left in the stream and the stream has reached at its end.
public long
length()

Implements io.netty.handler.stream.ChunkedInput.length.

Returns the length of the input.
public long
progress()

Implements io.netty.handler.stream.ChunkedInput.progress.

Returns current transfer progress.
public Http2DataFrame
readChunk(ChannelHandlerContext
The context which provides a ByteBufAllocator if buffer allocation is necessary.
ctx
)

Implements io.netty.handler.stream.ChunkedInput.readChunk.

Deprecated
public Http2DataFrame
readChunk(ByteBufAllocator
ByteBufAllocator if buffer allocation is necessary.
allocator
)

Implements io.netty.handler.stream.ChunkedInput.readChunk.

Fetches a chunked data from the stream.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

endStreamSentback to summary
private boolean endStreamSent
inputback to summary
private final ChunkedInput<ByteBuf> input
streamback to summary
private final Http2FrameStream stream

Constructor Detail

Http2DataChunkedInputback to summary
public Http2DataChunkedInput(ChunkedInput<ByteBuf> input, Http2FrameStream stream)

Creates a new instance using the specified input.

Parameters
input:ChunkedInput<ByteBuf>

ChunkedInput containing data to write

stream:Http2FrameStream

Http2FrameStream holding stream info

Method Detail

closeback to summary
public void close() throws Exception

Implements io.netty.handler.stream.ChunkedInput.close.

Doc from io.netty.handler.stream.ChunkedInput.close.

Releases the resources associated with the input.

Annotations
@Override
isEndOfInputback to summary
public boolean isEndOfInput() throws Exception

Implements io.netty.handler.stream.ChunkedInput.isEndOfInput.

Doc from io.netty.handler.stream.ChunkedInput.isEndOfInput.

Return true if and only if there is no data left in the stream and the stream has reached at its end.

Annotations
@Override
lengthback to summary
public long length()

Implements io.netty.handler.stream.ChunkedInput.length.

Doc from io.netty.handler.stream.ChunkedInput.length.

Returns the length of the input.

Returns:long

the length of the input if the length of the input is known. a negative value if the length of the input is unknown.

Annotations
@Override
progressback to summary
public long progress()

Implements io.netty.handler.stream.ChunkedInput.progress.

Doc from io.netty.handler.stream.ChunkedInput.progress.

Returns current transfer progress.

Annotations
@Override
readChunkback to summary
public Http2DataFrame readChunk(ChannelHandlerContext ctx) throws Exception

Implements io.netty.handler.stream.ChunkedInput.readChunk.

Deprecated

Parameters
ctx:ChannelHandlerContext

Doc from io.netty.handler.stream.ChunkedInput.readChunk.

The context which provides a ByteBufAllocator if buffer allocation is necessary.

Returns:Http2DataFrame

Doc from io.netty.handler.stream.ChunkedInput.readChunk.

the fetched chunk. null if there is no data left in the stream. Please note that null does not necessarily mean that the stream has reached at its end. In a slow stream, the next chunk might be unavailable just momentarily.

Annotations
@Deprecated
@Override
readChunkback to summary
public Http2DataFrame readChunk(ByteBufAllocator allocator) throws Exception

Implements io.netty.handler.stream.ChunkedInput.readChunk.

Doc from io.netty.handler.stream.ChunkedInput.readChunk.

Fetches a chunked data from the stream. Once this method returns the last chunk and thus the stream has reached at its end, any subsequent isEndOfInput() call must return true.

Parameters
allocator:ByteBufAllocator

ByteBufAllocator if buffer allocation is necessary.

Returns:Http2DataFrame

the fetched chunk. null if there is no data left in the stream. Please note that null does not necessarily mean that the stream has reached at its end. In a slow stream, the next chunk might be unavailable just momentarily.

Annotations
@Override