Package io.netty5.handler.codec.http
Class HttpChunkedInput
- java.lang.Object
-
- io.netty5.handler.codec.http.HttpChunkedInput
-
public class HttpChunkedInput extends Object
AChunkedInput
that 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,LastHttpContent
will 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); }