Class SessionOutputBufferImpl

java.lang.Object
org.apache.http.nio.util.ExpandableBuffer
org.apache.http.impl.nio.reactor.SessionOutputBufferImpl
All Implemented Interfaces:
BufferInfo, SessionOutputBuffer, BufferInfo

public class SessionOutputBufferImpl extends ExpandableBuffer implements SessionOutputBuffer
Default implementation of SessionOutputBuffer based on the ExpandableBuffer class.
Since:
4.0
  • Field Details

    • CRLF

      private static final byte[] CRLF
    • charEncoder

      private final CharsetEncoder charEncoder
    • lineBufferSize

      private final int lineBufferSize
    • charBuffer

      private CharBuffer charBuffer
  • Constructor Details

    • SessionOutputBufferImpl

      public SessionOutputBufferImpl(int bufferSize, int lineBufferSize, CharsetEncoder charEncoder, ByteBufferAllocator allocator)
      Creates SessionOutputBufferImpl instance.
      Parameters:
      bufferSize - input buffer size.
      lineBufferSize - buffer size for line operations. Has effect only if charEncoder is not null.
      charEncoder - CharEncoder to be used for encoding HTTP protocol elements. If null simple type cast will be used for char to byte conversion.
      allocator - memory allocator. If null HeapByteBufferAllocator.INSTANCE will be used.
      Since:
      4.3
    • SessionOutputBufferImpl

      @Deprecated public SessionOutputBufferImpl(int bufferSize, int lineBufferSize, ByteBufferAllocator allocator, HttpParams params)
    • SessionOutputBufferImpl

      @Deprecated public SessionOutputBufferImpl(int bufferSize, int lineBufferSize, HttpParams params)
    • SessionOutputBufferImpl

      public SessionOutputBufferImpl(int bufferSize)
      Creates SessionOutputBufferImpl instance.
      Parameters:
      bufferSize - input buffer size.
      Since:
      4.3
    • SessionOutputBufferImpl

      public SessionOutputBufferImpl(int bufferSize, int lineBufferSize, Charset charset)
      Creates SessionOutputBufferImpl instance.
      Parameters:
      bufferSize - input buffer size.
      lineBufferSize - buffer size for line operations. Has effect only if charset is not null.
      charset - Charset to be used for encoding HTTP protocol elements. If null simple type cast will be used for char to byte conversion.
      Since:
      4.3
    • SessionOutputBufferImpl

      public SessionOutputBufferImpl(int bufferSize, int lineBufferSize)
      Creates SessionOutputBufferImpl instance.
      Parameters:
      bufferSize - input buffer size.
      lineBufferSize - buffer size for line operations.
      Since:
      4.3
  • Method Details

    • reset

      public void reset(HttpParams params)
    • flush

      public int flush(WritableByteChannel channel) throws IOException
      Description copied from interface: SessionOutputBuffer
      Makes an attempt to flush the content of this buffer to the given destination WritableByteChannel.
      Specified by:
      flush in interface SessionOutputBuffer
      Parameters:
      channel - the destination channel.
      Returns:
      The number of bytes written, possibly zero.
      Throws:
      IOException - in case of an I/O error.
    • write

      public void write(ByteBuffer src)
      Description copied from interface: SessionOutputBuffer
      Copies content of the source buffer into this buffer. The capacity of the destination will be expanded in order to accommodate the entire content of the source buffer.
      Specified by:
      write in interface SessionOutputBuffer
      Parameters:
      src - the source buffer.
    • write

      public void write(ReadableByteChannel src) throws IOException
      Description copied from interface: SessionOutputBuffer
      Reads a sequence of bytes from the source channel into this buffer.
      Specified by:
      write in interface SessionOutputBuffer
      Parameters:
      src - the source channel.
      Throws:
      IOException
    • write

      private void write(byte[] b)
    • writeCRLF

      private void writeCRLF()
    • writeLine

      public void writeLine(CharArrayBuffer lineBuffer) throws CharacterCodingException
      Description copied from interface: SessionOutputBuffer
      Copies content of the source buffer into this buffer as one line of text including a line delimiter. The capacity of the destination will be expanded in order to accommodate the entire content of the source buffer.

      The choice of a char encoding and line delimiter sequence is up to the specific implementations of this interface.

      Specified by:
      writeLine in interface SessionOutputBuffer
      Parameters:
      lineBuffer - the source buffer.
      Throws:
      CharacterCodingException
    • writeLine

      public void writeLine(String s) throws IOException
      Description copied from interface: SessionOutputBuffer
      Copies content of the given string into this buffer as one line of text including a line delimiter. The capacity of the destination will be expanded in order to accommodate the entire string.

      The choice of a char encoding and line delimiter sequence is up to the specific implementations of this interface.

      Specified by:
      writeLine in interface SessionOutputBuffer
      Parameters:
      s - the string.
      Throws:
      IOException
    • clear

      public void clear()
      Description copied from class: ExpandableBuffer
      Clears buffer.
      Overrides:
      clear in class ExpandableBuffer