- java.lang.Object
-
- io.netty5.handler.codec.http.HttpChunkedInput
-
- All Implemented Interfaces:
io.netty5.handler.stream.ChunkedInput<HttpContent<?>>,AutoCloseable
public class HttpChunkedInput extends Object implements io.netty5.handler.stream.ChunkedInput<HttpContent<?>>
AChunkedInputthat fetches data chunk by chunk for use with HTTP chunked transfers.Each chunk from the input data will be wrapped within a
HttpContent. At the end of the input data,LastHttpContentwill be written.Ensure that your HTTP response header contains
Transfer-Encoding: chunked.public void messageReceived(ChannelHandlerContext ctx, FullHttpRequest request) throws Exception { HttpResponse response = new DefaultHttpResponse(HTTP_1_1, OK); response.headers().set(TRANSFER_ENCODING, CHUNKED); ctx.write(response); HttpContentChunkedInput httpChunkWriter = new HttpChunkedInput( new ChunkedFile("/tmp/myfile.txt")); Future<Void> sendFileFuture = ctx.write(httpChunkWriter); }
-
-
Constructor Summary
Constructors Constructor Description HttpChunkedInput(io.netty5.handler.stream.ChunkedInput<io.netty5.buffer.api.Buffer> input, LastHttpContent<?> lastHttpContent)Creates a new instance using the specified input.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()booleanisEndOfInput()longlength()longprogress()HttpContent<?>readChunk(io.netty5.buffer.api.BufferAllocator allocator)
-
-
-
Constructor Detail
-
HttpChunkedInput
public HttpChunkedInput(io.netty5.handler.stream.ChunkedInput<io.netty5.buffer.api.Buffer> input, LastHttpContent<?> lastHttpContent)Creates a new instance using the specified input.lastHttpContentwill be written as the terminating chunk.- Parameters:
input-ChunkedInputcontaining data to writelastHttpContent-LastHttpContentthat will be written as the terminating chunk. Use this for training headers.
-
-
Method Detail
-
isEndOfInput
public boolean isEndOfInput() throws Exception- Specified by:
isEndOfInputin interfaceio.netty5.handler.stream.ChunkedInput<HttpContent<?>>- Throws:
Exception
-
close
public void close() throws Exception- Specified by:
closein interfaceAutoCloseable- Throws:
Exception
-
readChunk
public HttpContent<?> readChunk(io.netty5.buffer.api.BufferAllocator allocator) throws Exception
- Specified by:
readChunkin interfaceio.netty5.handler.stream.ChunkedInput<HttpContent<?>>- Throws:
Exception
-
length
public long length()
- Specified by:
lengthin interfaceio.netty5.handler.stream.ChunkedInput<HttpContent<?>>
-
progress
public long progress()
- Specified by:
progressin interfaceio.netty5.handler.stream.ChunkedInput<HttpContent<?>>
-
-