public 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.
Constructor and Description |
---|
LengthDelimitedEncoder(WritableByteChannel channel,
SessionOutputBuffer buffer,
BasicHttpTransportMetrics metrics,
long contentLength) |
LengthDelimitedEncoder(WritableByteChannel channel,
SessionOutputBuffer buffer,
BasicHttpTransportMetrics metrics,
long contentLength,
int chunkSizeHint) |
Modifier and Type | Method and Description |
---|---|
String |
toString() |
long |
transfer(FileChannel src,
long position,
long count)
Transfers a portion of entity content from the given file channel
to the underlying network channel.
|
int |
write(ByteBuffer src)
Writes a portion of entity content to the underlying channel.
|
assertNotCompleted, buffer, channel, complete, complete, flushToChannel, isCompleted, metrics, writeToBuffer, writeToChannel, writeToChannel
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
complete, isCompleted
public LengthDelimitedEncoder(WritableByteChannel channel, SessionOutputBuffer buffer, BasicHttpTransportMetrics metrics, long contentLength, int chunkSizeHint)
channel
- underlying channel.buffer
- session buffer.metrics
- transport metrics.contentLength
- content length.chunkSizeHint
- 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(WritableByteChannel channel, SessionOutputBuffer buffer, BasicHttpTransportMetrics metrics, long contentLength)
public int write(ByteBuffer src) throws IOException
ContentEncoder
write
in interface ContentEncoder
src
- The buffer from which content is to be retrievedIOException
- if I/O error occurs while writing contentpublic long transfer(FileChannel src, long position, long count) throws IOException
FileContentEncoder
transfer
in interface FileContentEncoder
src
- 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-negativeIOException
- if some I/O error occurs.Copyright © 2005–2021 The Apache Software Foundation. All rights reserved.