public class

LengthDelimitedEncoder

extends AbstractContentEncoder
implements FileContentEncoder
java.lang.Object
   ↳ org.apache.http.impl.nio.codecs.AbstractContentEncoder
     ↳ org.apache.http.impl.nio.codecs.LengthDelimitedEncoder

Class Overview

Content encoder that cuts off after a defined number of bytes. This class is used to send content of HTTP messages where the end of the content entity is determined by the value of the Content-Length header. Entities transferred using this stream can be maximum 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.

Summary

[Expand]
Inherited Fields
From class org.apache.http.impl.nio.codecs.AbstractContentEncoder
Public Constructors
LengthDelimitedEncoder(WritableByteChannel channel, SessionOutputBuffer buffer, HttpTransportMetricsImpl metrics, long contentLength)
Public Methods
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.
[Expand]
Inherited Methods
From class org.apache.http.impl.nio.codecs.AbstractContentEncoder
From class java.lang.Object
From interface org.apache.http.nio.ContentEncoder
From interface org.apache.http.nio.FileContentEncoder

Public Constructors

public LengthDelimitedEncoder (WritableByteChannel channel, SessionOutputBuffer buffer, HttpTransportMetricsImpl metrics, long contentLength)

Public Methods

public String toString ()

public long transfer (FileChannel src, long position, long count)

Transfers a portion of entity content from the given file channel to the underlying network channel.

Parameters
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
Returns
  • The number of bytes, possibly zero, that were actually transferred
Throws
IOException

public int write (ByteBuffer src)

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