org.apache.coyote.http11

Class InternalAprOutputBuffer

public class InternalAprOutputBuffer extends Object implements OutputBuffer

Output buffer.

Author: Remy Maucherat

Nested Class Summary
protected classInternalAprOutputBuffer.SocketOutputBuffer
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 ByteBufferbbuf
Direct byte buffer used for writing.
protected byte[]buf
Pointer to the current write buffer.
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 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 longsocket
Underlying socket.
Constructor Summary
InternalAprOutputBuffer(Response response)
Default constructor.
InternalAprOutputBuffer(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.
protected voidflushBuffer()
Callback to write data from the buffer.
OutputFilter[]getFilters()
Get filters.
longgetSocket()
Get the underlying socket input stream.
voidnextRequest()
End processing of current HTTP request.
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.
voidsetSocket(long socket)
Set the underlying socket.
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).

bbuf

protected ByteBuffer bbuf
Direct byte buffer used for writing.

buf

protected byte[] buf
Pointer to the current write buffer.

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.

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.

socket

protected long socket
Underlying socket.

Constructor Detail

InternalAprOutputBuffer

public InternalAprOutputBuffer(Response response)
Default constructor.

InternalAprOutputBuffer

public InternalAprOutputBuffer(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

flushBuffer

protected void flushBuffer()
Callback to write data from the buffer.

getFilters

public OutputFilter[] getFilters()
Get filters.

getSocket

public long getSocket()
Get the underlying socket input 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.

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.

setSocket

public void setSocket(long socket)
Set the underlying socket.

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.