org.apache.coyote.http11

## Class InternalOutputBuffer

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

All Implemented Interfaces:
  OutputBuffer, ByteChunk.ByteOutputChannel

    public class InternalOutputBuffer
    extends AbstractOutputBuffer<Socket>
    implements ByteChunk.ByteOutputChannel

Output buffer.

Author:
  Remy Maucherat

### Nested Class Summary

Nested Classes
`protected class` `InternalOutputBuffer.OutputStreamOutputBuffer` This class is an output buffer which will write data to an output stream.

### Field Summary

Fields
`protected OutputStream` `outputStream` Underlying output stream.

### Fields inherited from class org.apache.coyote.http11.AbstractOutputBuffer

`activeFilters, buf, byteCount, committed, filterLibrary, finished, lastActiveFilter, outputStreamOutputBuffer, pos, response, sm`

### Constructor Summary

Constructors
Constructor and Description
`InternalOutputBuffer(Response response, int headerBufferSize)` Default constructor.

### Method Summary

Methods
`protected void` `commit()` Commit the response.
`void` `endRequest()` End request.
`void` `flush()` Flush the response.
`void` `init(SocketWrapper<Socket> socketWrapper, AbstractEndpoint endpoint)`
`void` `nextRequest()` End processing of current HTTP request.
`void` `realWriteBytes(byte[] cbuf, int off, int len)` Callback to write data from the buffer.
`void` `recycle()` Recycle the output buffer.
`void` `sendAck()` Send an acknowledgment.
`void` `setSocketBuffer(int socketBufferSize)` Set the socket buffer size.

### Methods inherited from class org.apache.coyote.http11.AbstractOutputBuffer

`addActiveFilter, addFilter, doWrite, endHeaders, getBytesWritten, getFilters, reset, sendHeader, sendStatus, write, write, write, write, write, write`

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

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

### Field Detail

#### outputStream

    protected OutputStream outputStream

Underlying output stream. Note: protected to assist with unit testing

### Constructor Detail

#### InternalOutputBuffer

    public InternalOutputBuffer(Response response,
                        int headerBufferSize)

Default constructor.

### Method Detail

#### setSocketBuffer

    public void setSocketBuffer(int socketBufferSize)

Set the socket buffer size.

#### init

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

Specified by:
  `init` in class `AbstractOutputBuffer<Socket>`
Throws:
  `IOException`

#### flush

    public void flush()
               throws IOException

Flush the response.

Overrides:
  `flush` in class `AbstractOutputBuffer<Socket>`
Throws:
  `IOException` - an underlying I/O error occurred

#### recycle

    public void recycle()

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

Overrides:
  `recycle` in class `AbstractOutputBuffer<Socket>`

#### 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.

Overrides:
  `nextRequest` in class `AbstractOutputBuffer<Socket>`

#### endRequest

    public void endRequest()
                    throws IOException

End request.

Overrides:
  `endRequest` in class `AbstractOutputBuffer<Socket>`
Throws:
  `IOException` - an underlying I/O error occurred

#### sendAck

    public void sendAck()
                 throws IOException

Send an acknowledgment.

Specified by:
  `sendAck` in class `AbstractOutputBuffer<Socket>`
Throws:
  `IOException`

#### commit

    protected void commit()
                   throws IOException

Commit the response.

Specified by:
  `commit` in class `AbstractOutputBuffer<Socket>`
Throws:
  `IOException` - an underlying I/O error occurred

#### realWriteBytes

    public void realWriteBytes(byte[] cbuf,
                      int off,
                      int len)
                        throws IOException

Callback to write data from the buffer.

Specified by:
  `realWriteBytes` in interface `ByteChunk.ByteOutputChannel`
Throws:
  `IOException`