public class IdentityEncoder extends AbstractContentEncoder implements FileContentEncoderContent encoder that writes data without any transformation. The end of the content entity is demarcated by closing the underlying connection (EOF condition). Entities transferred using this input stream can be of unlimited length.
This decoder is optimized to transfer data directly from a
FileChannelto the underlying I/O session's channel whenever possible avoiding intermediate buffering in the session buffer.
All Methods Instance Methods Concrete Methods Modifier and Type Method Description
transfer(FileChannel src, long position, long count)Transfers a portion of entity content from the given file channel to the underlying network channel.
write(ByteBuffer src)Writes a portion of entity content to the underlying channel.
Methods inherited from class org.apache.http.impl.nio.codecs.AbstractContentEncoder
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
public IdentityEncoder(WritableByteChannel channel, SessionOutputBuffer buffer, HttpTransportMetricsImpl metrics, int fragementSizeHint)
channel- underlying channel.
buffer- session buffer.
metrics- transport metrics.
fragementSizeHint- fragment size hint defining an minimal size of a fragment that should be written out directly to the channel bypassing the session buffer. Value
0disables fragment buffering.
public int write(ByteBuffer src) throws IOExceptionDescription copied from interface:
ContentEncoderWrites a portion of entity content to the underlying channel.
public long transfer(FileChannel src, long position, long count) throws IOExceptionDescription copied from interface:
FileContentEncoderTransfers a portion of entity content from the given file channel to the underlying network channel.
- Specified by:
src- the source FileChannel to transfer data from.
position- The position within the file at which the transfer is to begin; must be non-negative
count- The maximum number of bytes to be transferred; must be non-negative
- The number of bytes, possibly zero, that were actually transferred
IOException- if some I/O error occurs.