org.apache.coyote.http11

Class InternalNioOutputBuffer

public class InternalNioOutputBuffer extends Object implements OutputBuffer

Output buffer.

Author: Remy Maucherat Filip Hanik

Nested Class Summary
protected classInternalNioOutputBuffer.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 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 MutableIntegerlastWrite
Number of bytes last written
protected OutputBufferoutputStreamOutputBuffer
Underlying output buffer.
protected NioSelectorPoolpool
Selector pool, for blocking reads and blocking writes
protected intpos
Position in the buffer.
protected Responseresponse
Associated Coyote response.
protected static StringManagersm
The string manager for this package.
protected NioChannelsocket
Underlying socket.
Constructor Summary
InternalNioOutputBuffer(Response response)
Default constructor.
InternalNioOutputBuffer(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.
NioSelectorPoolgetSelectorPool()
NioChannelgetSocket()
Get the underlying socket input stream.
booleanisWritable()
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.
voidsetSelectorPool(NioSelectorPool pool)
voidsetSocket(NioChannel 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).

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.

lastWrite

protected MutableInteger lastWrite
Number of bytes last written

outputStreamOutputBuffer

protected OutputBuffer outputStreamOutputBuffer
Underlying output buffer.

pool

protected NioSelectorPool pool
Selector pool, for blocking reads and blocking writes

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 NioChannel socket
Underlying socket.

Constructor Detail

InternalNioOutputBuffer

public InternalNioOutputBuffer(Response response)
Default constructor.

InternalNioOutputBuffer

public InternalNioOutputBuffer(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.

getSelectorPool

public NioSelectorPool getSelectorPool()

getSocket

public NioChannel getSocket()
Get the underlying socket input stream.

isWritable

public boolean isWritable()

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.

setSelectorPool

public void setSelectorPool(NioSelectorPool pool)

setSocket

public void setSocket(NioChannel 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.