Class ChunkEncoder
java.lang.Object
org.apache.hc.core5.http.impl.nio.AbstractContentEncoder
org.apache.hc.core5.http.impl.nio.ChunkEncoder
- All Implemented Interfaces:
ContentEncoder
Implements chunked transfer coding. The content is sent in small chunks.
Entities transferred using this decoder can be of unlimited length.
- Since:
- 4.0
-
Field Summary
FieldsFields inherited from class org.apache.hc.core5.http.impl.nio.AbstractContentEncoder
buffer, channel, completed, metrics
-
Constructor Summary
ConstructorsConstructorDescriptionChunkEncoder
(WritableByteChannel channel, SessionOutputBuffer buffer, BasicHttpTransportMetrics metrics) ChunkEncoder
(WritableByteChannel channel, SessionOutputBuffer buffer, BasicHttpTransportMetrics metrics, int chunkSizeHint) -
Method Summary
Modifier and TypeMethodDescriptionvoid
Terminates the content stream.toString()
int
write
(ByteBuffer src) Writes a portion of entity content to the underlying channel.private void
writeTrailers
(List<? extends Header> trailers) Methods inherited from class org.apache.hc.core5.http.impl.nio.AbstractContentEncoder
assertNotCompleted, buffer, channel, complete, flushToChannel, isCompleted, metrics, writeToBuffer, writeToChannel, writeToChannel
-
Field Details
-
chunkSizeHint
private final int chunkSizeHint -
lineBuffer
-
-
Constructor Details
-
ChunkEncoder
public ChunkEncoder(WritableByteChannel channel, SessionOutputBuffer buffer, BasicHttpTransportMetrics metrics, int chunkSizeHint) - Parameters:
channel
- underlying channel.buffer
- session buffer.metrics
- transport metrics.- Since:
- 5.0
-
ChunkEncoder
public ChunkEncoder(WritableByteChannel channel, SessionOutputBuffer buffer, BasicHttpTransportMetrics metrics)
-
-
Method Details
-
write
Description copied from interface:ContentEncoder
Writes a portion of entity content to the underlying channel.- Parameters:
src
- The buffer from which content is to be retrieved- Returns:
- The number of bytes read, possibly zero
- Throws:
IOException
- if I/O error occurs while writing content
-
complete
Description copied from interface:ContentEncoder
Terminates the content stream.- Specified by:
complete
in interfaceContentEncoder
- Overrides:
complete
in classAbstractContentEncoder
- Throws:
IOException
- if I/O error occurs while writing content
-
writeTrailers
- Throws:
IOException
-
toString
-