org.apache.hc.core5.http.nio

## Interface SessionOutputBuffer

-     public interface SessionOutputBuffer

  Session output buffer for non-blocking HTTP/1.1 connections.

  This interface facilitates intermediate buffering of output data streamed out to a destination channel and provides provides methods for writing lines of text.

  Since:
    4.0

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `capacity()` Returns available space in the buffer.
    `int` | `flush(WritableByteChannel channel)` Makes an attempt to flush the content of this buffer to the given destination `WritableByteChannel`.
    `boolean` | `hasData()` Determines if the buffer contains data.
    `int` | `length()` Returns the length of this buffer.
    `void` | `write(ByteBuffer src)` Copies content of the source buffer into this buffer.
    `void` | `write(ReadableByteChannel src)` Reads a sequence of bytes from the source channel into this buffer.
    `void` | `writeLine(CharArrayBuffer src)` Copies content of the source buffer into this buffer as one line of text including a line delimiter.

- - ### Method Detail

    - #### hasData

          boolean hasData()

      Determines if the buffer contains data.
      Returns:
        `true` if there is data in the buffer, `false` otherwise.

    - #### capacity

          int capacity()

      Returns available space in the buffer.
      Returns:
        available space.

    - #### length

          int length()

      Returns the length of this buffer.
      Returns:
        buffer length.

    - #### flush

          int flush(WritableByteChannel channel)
             throws IOException

      Makes an attempt to flush the content of this buffer to the given destination `WritableByteChannel`.
      Parameters:
        `channel` - the destination channel.
      Returns:
        The number of bytes written, possibly zero.
      Throws:
        `IOException` - in case of an I/O error.

    - #### write

          void write(ByteBuffer src)

      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.
      Parameters:
        `src` - the source buffer.

    - #### write

          void write(ReadableByteChannel src)
              throws IOException

      Reads a sequence of bytes from the source channel into this buffer.
      Parameters:
        `src` - the source channel.
      Throws:
        `IOException`

    - #### writeLine

          void writeLine(CharArrayBuffer src)
                  throws CharacterCodingException

      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.

      Parameters:
        `src` - the source buffer.
      Throws:
        `CharacterCodingException`

Copyright © 2005–2021 The Apache Software Foundation. All rights reserved.