Module io.netty5.codec.http
Class WebSocketChunkedInput
- java.lang.Object
-
- io.netty5.handler.codec.http.websocketx.WebSocketChunkedInput
-
- All Implemented Interfaces:
ChunkedInput<WebSocketFrame>
,AutoCloseable
public final class WebSocketChunkedInput extends Object implements ChunkedInput<WebSocketFrame>
AChunkedInput
that fetches data chunk by chunk for use with WebSocket chunked transfers.Each chunk from the input data will be wrapped within a
ContinuationWebSocketFrame
. At the end of the input data,ContinuationWebSocketFrame
with finalFragment will be written.
-
-
Constructor Summary
Constructors Constructor Description WebSocketChunkedInput(ChunkedInput<Buffer> input)
Creates a new instance using the specified input.WebSocketChunkedInput(ChunkedInput<Buffer> input, int rsv)
Creates a new instance using the specified input.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Releases the resources associated with the input.boolean
isEndOfInput()
Returntrue
if and only if there is no data left in the stream and the stream has reached at its end.long
length()
Returns the length of the input.long
progress()
Returns current transfer progress.WebSocketFrame
readChunk(BufferAllocator allocator)
Fetches a chunked data from the stream.
-
-
-
Constructor Detail
-
WebSocketChunkedInput
public WebSocketChunkedInput(ChunkedInput<Buffer> input)
Creates a new instance using the specified input.- Parameters:
input
-ChunkedInput
containing data to write
-
WebSocketChunkedInput
public WebSocketChunkedInput(ChunkedInput<Buffer> input, int rsv)
Creates a new instance using the specified input.- Parameters:
input
-ChunkedInput
containing data to writersv
- RSV1, RSV2, RSV3 used for extensions- Throws:
NullPointerException
- ifinput
is null
-
-
Method Detail
-
isEndOfInput
public boolean isEndOfInput() throws Exception
Description copied from interface:ChunkedInput
Returntrue
if and only if there is no data left in the stream and the stream has reached at its end.- Specified by:
isEndOfInput
in interfaceChunkedInput<WebSocketFrame>
- Returns:
true
if and only if there is no data left in the stream and the stream has reached at its end.- Throws:
Exception
-
close
public void close() throws Exception
Releases the resources associated with the input.- Specified by:
close
in interfaceAutoCloseable
- Throws:
Exception
-
readChunk
public WebSocketFrame readChunk(BufferAllocator allocator) throws Exception
Fetches a chunked data from the stream. Once this method returns the last chunk and thus the stream has reached at its end, any subsequentisEndOfInput()
call must returntrue
.- Specified by:
readChunk
in interfaceChunkedInput<WebSocketFrame>
- Parameters:
allocator
-BufferAllocator
- Returns:
WebSocketFrame
contain chunk of data- Throws:
Exception
-
length
public long length()
Description copied from interface:ChunkedInput
Returns the length of the input.- Specified by:
length
in interfaceChunkedInput<WebSocketFrame>
- Returns:
- the length of the input if the length of the input is known. a negative value if the length of the input is unknown.
-
progress
public long progress()
Description copied from interface:ChunkedInput
Returns current transfer progress.- Specified by:
progress
in interfaceChunkedInput<WebSocketFrame>
-
-