ContentEncoder, FileContentEncoderpublic class LengthDelimitedEncoder extends AbstractContentEncoder implements FileContentEncoder
Content-Length header.
Entities transferred using this stream can be maximum Long.MAX_VALUE
long.
This decoder is optimized to transfer data directly from
a FileChannel to the underlying I/O session's channel whenever
possible avoiding intermediate buffering in the session buffer.
buffer, channel, completed, metrics| Constructor | Description |
|---|---|
LengthDelimitedEncoder(java.nio.channels.WritableByteChannel channel,
SessionOutputBuffer buffer,
org.apache.http.impl.io.HttpTransportMetricsImpl metrics,
long contentLength) |
|
LengthDelimitedEncoder(java.nio.channels.WritableByteChannel channel,
SessionOutputBuffer buffer,
org.apache.http.impl.io.HttpTransportMetricsImpl metrics,
long contentLength,
int fragementSizeHint) |
| Modifier and Type | Method | Description |
|---|---|---|
java.lang.String |
toString() |
|
long |
transfer(java.nio.channels.FileChannel src,
long position,
long count) |
Transfers a portion of entity content from the given file channel
to the underlying network channel.
|
int |
write(java.nio.ByteBuffer src) |
Writes a portion of entity content to the underlying channel.
|
assertNotCompleted, complete, flushToChannel, isCompleted, writeToBuffer, writeToChannel, writeToChannelcomplete, isCompletedpublic LengthDelimitedEncoder(java.nio.channels.WritableByteChannel channel,
SessionOutputBuffer buffer,
org.apache.http.impl.io.HttpTransportMetricsImpl metrics,
long contentLength,
int fragementSizeHint)
channel - underlying channel.buffer - session buffer.metrics - transport metrics.contentLength - content length.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 0 disables fragment buffering.public LengthDelimitedEncoder(java.nio.channels.WritableByteChannel channel,
SessionOutputBuffer buffer,
org.apache.http.impl.io.HttpTransportMetricsImpl metrics,
long contentLength)
public int write(java.nio.ByteBuffer src)
throws java.io.IOException
ContentEncoderwrite in interface ContentEncodersrc - The buffer from which content is to be retrievedjava.io.IOException - if I/O error occurs while writing contentpublic long transfer(java.nio.channels.FileChannel src,
long position,
long count)
throws java.io.IOException
FileContentEncodertransfer in interface FileContentEncodersrc - the source FileChannel to transfer data from.position - The position within the file at which the transfer is to begin;
must be non-negativecount - The maximum number of bytes to be transferred; must be
non-negativejava.io.IOException - if some I/O error occurs.public java.lang.String toString()
toString in class java.lang.Object