AbstractOutputBuffer (Apache Tomcat 7.0.103 API Documentation)

org.apache.coyote.http11

## Class AbstractOutputBuffer<S>

- java.lang.Object
- - org.apache.coyote.http11.AbstractOutputBuffer<S>

- All Implemented Interfaces:
    OutputBuffer
  Direct Known Subclasses:
    InternalAprOutputBuffer, InternalNioOutputBuffer, InternalOutputBuffer

      public abstract class AbstractOutputBuffer<S>
      extends Object
      implements OutputBuffer

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected OutputFilter[]` | `activeFilters` Active filter (which is actually the top of the pipeline).
    `protected byte[]` | `buf` The buffer used for header composition.
    `protected long` | `byteCount` Bytes written to client for the current request
    `protected boolean` | `committed` Committed flag.
    `protected OutputFilter[]` | `filterLibrary` Filter library.
    `protected boolean` | `finished` Finished flag.
    `protected int` | `lastActiveFilter` Index of the last active filter.
    `protected OutputBuffer` | `outputStreamOutputBuffer` Underlying output buffer.
    `protected int` | `pos` Position in the buffer.
    `protected Response` | `response` Associated Coyote response.
    `protected static StringManager` | `sm` The string manager for this package.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractOutputBuffer()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addActiveFilter(OutputFilter filter)` Add an output filter to the filter library.
    `void` | `addFilter(OutputFilter filter)` Add an output filter to the filter library.
    `protected abstract void` | `commit()`
    `int` | `doWrite(ByteChunk chunk, Response res)` Write the contents of a byte chunk.
    `void` | `endHeaders()` End the header block.
    `void` | `endRequest()` End request.
    `void` | `flush()` Flush the response.
    `long` | `getBytesWritten()` Bytes written to the underlying socket.
    `OutputFilter[]` | `getFilters()` Get filters.
    `abstract void` | `init(SocketWrapper<S> socketWrapper, AbstractEndpoint<S> endpoint)`
    `void` | `nextRequest()` End processing of current HTTP request.
    `void` | `recycle()` Recycle the output buffer.
    `void` | `reset()` Reset current response.
    `abstract void` | `sendAck()`
    `void` | `sendHeader(MessageBytes name, MessageBytes value)` Send a header.
    `void` | `sendStatus()` Send the response status line.
    `void` | `write(byte[] b)` This method will write the contents of the specified byte buffer to the output stream, without filtering.
    `protected void` | `write(ByteChunk bc)` This method will write the contents of the specified message bytes buffer to the output stream, without filtering.
    `protected void` | `write(CharChunk cc)` This method will write the contents of the specified char buffer to the output stream, without filtering.
    `protected void` | `write(int i)` This method will print the specified integer to the output stream, without filtering.
    `protected void` | `write(MessageBytes mb)` This method will write the contents of the specified message bytes buffer to the output stream, without filtering.
    `protected void` | `write(String s)` This method will write the contents of the specified String to the output stream, without filtering.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### response

          protected Response response

      Associated Coyote response.

    - #### committed

          protected boolean committed

      Committed flag.

    - #### finished

          protected boolean finished

      Finished flag.

    - #### buf

          protected byte[] buf

      The buffer used for header composition.

    - #### pos

          protected int pos

      Position in the buffer.

    - #### filterLibrary

          protected OutputFilter[] filterLibrary

      Filter library. Note: Filter[0] is always the "chunked" filter.

    - #### activeFilters

          protected OutputFilter[] activeFilters

      Active filter (which is actually the top of the pipeline).

    - #### lastActiveFilter

          protected int lastActiveFilter

      Index of the last active filter.

    - #### outputStreamOutputBuffer

          protected OutputBuffer outputStreamOutputBuffer

      Underlying output buffer.

    - #### byteCount

          protected long byteCount

      Bytes written to client for the current request

    - #### sm

          protected static final StringManager sm

      The string manager for this package.

  - ### Constructor Detail

    - #### AbstractOutputBuffer

          public AbstractOutputBuffer()

  - ### Method Detail

    - #### addFilter

          public void addFilter(OutputFilter filter)

      Add an output filter to the filter library.

    - #### getFilters

          public OutputFilter[] getFilters()

      Get filters.

    - #### addActiveFilter

          public void addActiveFilter(OutputFilter filter)

      Add an output filter to the filter library.

    - #### doWrite

          public int doWrite(ByteChunk chunk,
                    Response res)
                      throws IOException

      Write the contents of a byte chunk.
      Specified by:
        `doWrite` in interface `OutputBuffer`
      Parameters:
        `chunk` - byte chunk
        `res` - The response to which the data should be written. (Should be the response already associated with the OutputBuffer).
      Returns:
        number of bytes written
      Throws:
        `IOException` - an underlying I/O error occurred

    - #### getBytesWritten

          public long getBytesWritten()

      Description copied from interface: `OutputBuffer`
      Bytes written to the underlying socket. This includes the effects of chunking, compression, etc.
      Specified by:
        `getBytesWritten` in interface `OutputBuffer`
      Returns:
        Bytes written for the current request

    - #### flush

          public void flush()
                     throws IOException

      Flush the response.
      Throws:
        `IOException` - an underlying I/O error occurred

    - #### reset

          public void reset()

      Reset current response.
      Throws:
        `IllegalStateException` - if the response has already been committed

    - #### recycle

          public void recycle()

      Recycle the output buffer. This should be called when closing the connection.

    - #### nextRequest

          public void nextRequest()

      End processing of current HTTP request. Note: All bytes of the current request should have been already consumed. This method only resets all the pointers so that we are ready to parse the next HTTP request.

    - #### endRequest

          public void endRequest()
                          throws IOException

      End request.
      Throws:
        `IOException` - an underlying I/O error occurred

    - #### init

          public abstract void init(SocketWrapper<S> socketWrapper,
                  AbstractEndpoint<S> endpoint)
                             throws IOException

      Throws:
        `IOException`

    - #### sendAck

          public abstract void sendAck()
                                throws IOException

      Throws:
        `IOException`

    - #### commit

          protected abstract void commit()
                                  throws IOException

      Throws:
        `IOException`

    - #### sendStatus

          public void sendStatus()

      Send the response status line.

    - #### sendHeader

          public void sendHeader(MessageBytes name,
                        MessageBytes value)

      Send a header.
      Parameters:
        `name` - Header name
        `value` - Header value

    - #### endHeaders

          public void endHeaders()

      End the header block.

    - #### write

          protected void write(MessageBytes mb)

      This method will write the contents of the specified message bytes buffer to the output stream, without filtering. This method is meant to be used to write the response header.
      Parameters:
        `mb` - data to be written

    - #### write

          protected void write(ByteChunk bc)

      This method will write the contents of the specified message bytes buffer to the output stream, without filtering. This method is meant to be used to write the response header.
      Parameters:
        `bc` - data to be written

    - #### write

          protected void write(CharChunk cc)

      This method will write the contents of the specified char buffer to the output stream, without filtering. This method is meant to be used to write the response header.
      Parameters:
        `cc` - data to be written

    - #### write

          public void write(byte[] b)

      This method will write the contents of the specified byte buffer to the output stream, without filtering. This method is meant to be used to write the response header.
      Parameters:
        `b` - data to be written

    - #### write

          protected void write(String s)

      This method will write the contents of the specified String to the output stream, without filtering. This method is meant to be used to write the response header.
      Parameters:
        `s` - data to be written

    - #### write

          protected void write(int i)

      This method will print the specified integer to the output stream, without filtering. This method is meant to be used to write the response header.
      Parameters:
        `i` - data to be written

Copyright © 2000-2020 Apache Software Foundation. All Rights Reserved.