org.apache.coyote.http11

Class InternalOutputBuffer

public class InternalOutputBuffer extends Object implements OutputBuffer, ByteChunk.ByteOutputChannel

Output buffer.

Author: Remy Maucherat

Nested Class Summary
protected classInternalOutputBuffer.OutputStreamOutputBuffer
This class is an output buffer which will write data to an output stream.
Field Summary
protected OutputFilter[]activeFilters
Active filter (which is actually the top of the pipeline).
protected byte[]buf
The buffer used for header composition.
protected booleancommitted
Committed flag.
protected OutputFilter[]filterLibrary
Filter library.
protected booleanfinished
Finished flag.
protected MimeHeadersheaders
Headers of the associated request.
protected intlastActiveFilter
Index of the last active filter.
protected OutputStreamoutputStream
Underlying output stream.
protected OutputBufferoutputStreamOutputBuffer
Underlying output buffer.
protected intpos
Position in the buffer.
protected Responseresponse
Associated Coyote response.
protected static StringManagersm
The string manager for this package.
protected ByteChunksocketBuffer
Socket buffer.
protected booleanuseSocketBuffer
Socket buffer (extra buffering to reduce number of packets sent).
Constructor Summary
InternalOutputBuffer(Response response)
Default constructor.
InternalOutputBuffer(Response response, int headerBufferSize)
Alternate constructor.
Method Summary
voidaddActiveFilter(OutputFilter filter)
Add an output filter to the filter library.
voidaddFilter(OutputFilter filter)
Add an output filter to the filter library.
voidclearFilters()
Clear filters.
protected voidcommit()
Commit the response.
intdoWrite(ByteChunk chunk, Response res)
Write the contents of a byte chunk.
voidendHeaders()
End the header block.
voidendRequest()
End request.
voidflush()
Flush the response.
OutputFilter[]getFilters()
Get filters.
OutputStreamgetOutputStream()
Get the underlying socket output stream.
voidnextRequest()
End processing of current HTTP request.
voidrealWriteBytes(byte[] cbuf, int off, int len)
Callback to write data from the buffer.
voidrecycle()
Recycle the output buffer.
voidreset()
Reset current response.
voidsendAck()
Send an acknoledgement.
voidsendHeader(MessageBytes name, MessageBytes value)
Send a header.
voidsendHeader(ByteChunk name, ByteChunk value)
Send a header.
voidsendHeader(String name, String value)
Send a header.
voidsendStatus()
Send the response status line.
voidsetOutputStream(OutputStream outputStream)
Set the underlying socket output stream.
voidsetSocketBuffer(int socketBufferSize)
Set the socket buffer size.
protected voidwrite(MessageBytes mb)
This method will write the contents of the specyfied message bytes buffer to the output stream, without filtering.
protected voidwrite(ByteChunk bc)
This method will write the contents of the specyfied message bytes buffer to the output stream, without filtering.
protected voidwrite(CharChunk cc)
This method will write the contents of the specyfied char buffer to the output stream, without filtering.
voidwrite(byte[] b)
This method will write the contents of the specyfied byte buffer to the output stream, without filtering.
protected voidwrite(String s)
This method will write the contents of the specyfied String to the output stream, without filtering.
protected voidwrite(int i)
This method will print the specified integer to the output stream, without filtering.

Field Detail

activeFilters

protected OutputFilter[] activeFilters
Active filter (which is actually the top of the pipeline).

buf

protected byte[] buf
The buffer used for header composition.

committed

protected boolean committed
Committed flag.

filterLibrary

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

finished

protected boolean finished
Finished flag.

headers

protected MimeHeaders headers
Headers of the associated request.

lastActiveFilter

protected int lastActiveFilter
Index of the last active filter.

outputStream

protected OutputStream outputStream
Underlying output stream.

outputStreamOutputBuffer

protected OutputBuffer outputStreamOutputBuffer
Underlying output buffer.

pos

protected int pos
Position in the buffer.

response

protected Response response
Associated Coyote response.

sm

protected static StringManager sm
The string manager for this package.

socketBuffer

protected ByteChunk socketBuffer
Socket buffer.

useSocketBuffer

protected boolean useSocketBuffer
Socket buffer (extra buffering to reduce number of packets sent).

Constructor Detail

InternalOutputBuffer

public InternalOutputBuffer(Response response)
Default constructor.

InternalOutputBuffer

public InternalOutputBuffer(Response response, int headerBufferSize)
Alternate constructor.

Method Detail

addActiveFilter

public void addActiveFilter(OutputFilter filter)
Add an output filter to the filter library.

addFilter

public void addFilter(OutputFilter filter)
Add an output filter to the filter library.

clearFilters

public void clearFilters()
Clear filters.

commit

protected void commit()
Commit the response.

Throws: IOException an undelying I/O error occured

doWrite

public int doWrite(ByteChunk chunk, Response res)
Write the contents of a byte chunk.

Parameters: chunk byte chunk

Returns: number of bytes written

Throws: IOException an undelying I/O error occured

endHeaders

public void endHeaders()
End the header block.

endRequest

public void endRequest()
End request.

Throws: IOException an undelying I/O error occured

flush

public void flush()
Flush the response.

Throws: IOException an undelying I/O error occured

getFilters

public OutputFilter[] getFilters()
Get filters.

getOutputStream

public OutputStream getOutputStream()
Get the underlying socket output stream.

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.

realWriteBytes

public void realWriteBytes(byte[] cbuf, int off, int len)
Callback to write data from the buffer.

recycle

public void recycle()
Recycle the output buffer. This should be called when closing the connection.

reset

public void reset()
Reset current response.

Throws: IllegalStateException if the response has already been committed

sendAck

public void sendAck()
Send an acknoledgement.

sendHeader

public void sendHeader(MessageBytes name, MessageBytes value)
Send a header.

Parameters: name Header name value Header value

sendHeader

public void sendHeader(ByteChunk name, ByteChunk value)
Send a header.

Parameters: name Header name value Header value

sendHeader

public void sendHeader(String name, String value)
Send a header.

Parameters: name Header name value Header value

sendStatus

public void sendStatus()
Send the response status line.

setOutputStream

public void setOutputStream(OutputStream outputStream)
Set the underlying socket output stream.

setSocketBuffer

public void setSocketBuffer(int socketBufferSize)
Set the socket buffer size.

write

protected void write(MessageBytes mb)
This method will write the contents of the specyfied 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 specyfied 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 specyfied 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 specyfied 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 specyfied 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-2011 Apache Software Foundation. All Rights Reserved.