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
public class ChunkEncoder extends AbstractContentEncoder
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
Fields Modifier and Type Field Description private int
chunkSizeHint
private CharArrayBuffer
lineBuffer
-
Fields inherited from class org.apache.hc.core5.http.impl.nio.AbstractContentEncoder
buffer, channel, completed, metrics
-
-
Constructor Summary
Constructors Constructor Description ChunkEncoder(java.nio.channels.WritableByteChannel channel, SessionOutputBuffer buffer, BasicHttpTransportMetrics metrics)
ChunkEncoder(java.nio.channels.WritableByteChannel channel, SessionOutputBuffer buffer, BasicHttpTransportMetrics metrics, int chunkSizeHint)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
complete(java.util.List<? extends Header> trailers)
Terminates the content stream.java.lang.String
toString()
int
write(java.nio.ByteBuffer src)
Writes a portion of entity content to the underlying channel.private void
writeTrailers(java.util.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 Detail
-
chunkSizeHint
private final int chunkSizeHint
-
lineBuffer
private final CharArrayBuffer lineBuffer
-
-
Constructor Detail
-
ChunkEncoder
public ChunkEncoder(java.nio.channels.WritableByteChannel channel, SessionOutputBuffer buffer, BasicHttpTransportMetrics metrics, int chunkSizeHint)
- Parameters:
channel
- underlying channel.buffer
- session buffer.metrics
- transport metrics.- Since:
- 5.0
-
ChunkEncoder
public ChunkEncoder(java.nio.channels.WritableByteChannel channel, SessionOutputBuffer buffer, BasicHttpTransportMetrics metrics)
-
-
Method Detail
-
write
public int write(java.nio.ByteBuffer src) throws java.io.IOException
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:
java.io.IOException
- if I/O error occurs while writing content
-
complete
public void complete(java.util.List<? extends Header> trailers) throws java.io.IOException
Description copied from interface:ContentEncoder
Terminates the content stream.- Specified by:
complete
in interfaceContentEncoder
- Overrides:
complete
in classAbstractContentEncoder
- Throws:
java.io.IOException
- if I/O error occurs while writing content
-
writeTrailers
private void writeTrailers(java.util.List<? extends Header> trailers) throws java.io.IOException
- Throws:
java.io.IOException
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-