org.apache.coyote.http11

Class InternalOutputBuffer

Implemented Interfaces:
ByteChunk.ByteOutputChannel, OutputBuffer

public class InternalOutputBuffer
extends java.lang.Object
implements OutputBuffer, ByteChunk.ByteOutputChannel

Output buffer.

Author:
Remy Maucherat

Nested Class Summary

protected class
InternalOutputBuffer.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
Pointer to the current read buffer.
protected boolean
committed
Committed flag.
protected OutputFilter[]
filterLibrary
Filter library.
protected boolean
finished
Finished flag.
protected byte[]
headerBuffer
HTTP header buffer.
protected MimeHeaders
headers
Headers of the associated request.
protected int
lastActiveFilter
Index of the last active filter.
protected OutputStream
outputStream
Underlying output stream.
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.
protected ByteChunk
socketBuffer
Socket buffer.
protected boolean
useSocketBuffer
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

void
addActiveFilter(OutputFilter filter)
Add an output filter to the filter library.
void
addFilter(OutputFilter filter)
Add an output filter to the filter library.
void
clearFilters()
Clear filters.
protected void
commit()
Commit the response.
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.
OutputFilter[]
getFilters()
Get filters.
OutputStream
getOutputStream()
Get the underlying socket output stream.
void
nextRequest()
End processing of current HTTP request.
void
realWriteBytes(cbuf[] , int off, int len)
Callback to write data from the buffer.
void
recycle()
Recycle the output buffer.
void
reset()
Reset current response.
void
sendAck()
Send an acknoledgement.
void
sendHeader(String name, String value)
Send a header.
void
sendHeader(ByteChunk name, ByteChunk value)
Send a header.
void
sendHeader(MessageBytes name, MessageBytes value)
Send a header.
void
sendStatus()
Send the response status line.
void
setOutputStream(OutputStream outputStream)
Set the underlying socket output stream.
void
setSocketBuffer(int socketBufferSize)
Set the socket buffer size.
protected void
write(String s)
This method will write the contents of the specyfied String to the output stream, without filtering.
protected void
write(byte[] b)
This method will write the contents of the specyfied byte 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(ByteChunk bc)
This method will write the contents of the specyfied message bytes buffer to the output stream, without filtering.
protected void
write(MessageBytes mb)
This method will write the contents of the specyfied message bytes buffer to the output stream, without filtering.

Field Details

activeFilters

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


buf

protected byte[] buf
Pointer to the current read 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.


headerBuffer

protected byte[] headerBuffer
HTTP header buffer.


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 Details

InternalOutputBuffer

public InternalOutputBuffer(Response response)
Default constructor.


InternalOutputBuffer

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

Method Details

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()
            throws IOException
Commit the response.


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

Returns:
number of bytes written


endHeaders

public void endHeaders()
End the header block.


endRequest

public void endRequest()
            throws IOException
End request.


flush

public void flush()
            throws IOException
Flush the response.


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(cbuf[] ,
                           int off,
                           int len)
            throws IOException
Callback to write data from the buffer.
Specified by:
realWriteBytes in interface ByteChunk.ByteOutputChannel


recycle

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


reset

public void reset()
Reset current response.


sendAck

public void sendAck()
            throws IOException
Send an acknoledgement.


sendHeader

public void sendHeader(String name,
                       String 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(MessageBytes name,
                       MessageBytes 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(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(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(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


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


Copyright B) 2000-2003 Apache Software Foundation. All Rights Reserved.