Apache Tomcat 6.0.53

org.apache.coyote.http11
Class InternalAprOutputBuffer

java.lang.Object
  extended by org.apache.coyote.http11.InternalAprOutputBuffer
All Implemented Interfaces:
OutputBuffer

public class InternalAprOutputBuffer
extends java.lang.Object
implements OutputBuffer

Output buffer.

Author:
Remy Maucherat

Nested Class Summary
protected  class InternalAprOutputBuffer.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  java.nio.ByteBuffer bbuf
          Direct byte buffer used for writing.
protected  byte[] buf
          Pointer to the current write buffer.
protected  boolean committed
          Committed flag.
protected  OutputFilter[] filterLibrary
          Filter library.
protected  boolean finished
          Finished flag.
protected  MimeHeaders headers
          Headers of the associated request.
protected  int lastActiveFilter
          Index of the last active filter.
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  long socket
          Underlying socket.
 
Constructor Summary
InternalAprOutputBuffer(Response response)
          Default constructor.
InternalAprOutputBuffer(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.
protected  void flushBuffer()
          Callback to write data from the buffer.
 OutputFilter[] getFilters()
          Get filters.
 long getSocket()
          Get the underlying socket input stream.
 void nextRequest()
          End processing of current HTTP request.
 void recycle()
          Recycle the output buffer.
 void reset()
          Reset current response.
 void sendAck()
          Send an acknoledgement.
 void sendHeader(ByteChunk name, ByteChunk value)
          Send a header.
 void sendHeader(MessageBytes name, MessageBytes value)
          Send a header.
 void sendHeader(java.lang.String name, java.lang.String value)
          Send a header.
 void sendStatus()
          Send the response status line.
 void setSocket(long socket)
          Set the underlying socket.
 void setSocketBuffer(int socketBufferSize)
          Set the socket buffer size.
 void write(byte[] b)
          This method will write the contents of the specyfied byte buffer 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(CharChunk cc)
          This method will write the contents of the specyfied char 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(MessageBytes mb)
          This method will write the contents of the specyfied message bytes buffer to the output stream, without filtering.
protected  void write(java.lang.String s)
          This method will write the contents of the specyfied String to the output stream, without filtering.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sm

protected static StringManager sm
The string manager for this package.


response

protected Response response
Associated Coyote response.


headers

protected MimeHeaders headers
Headers of the associated request.


committed

protected boolean committed
Committed flag.


finished

protected boolean finished
Finished flag.


buf

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


pos

protected int pos
Position in the buffer.


socket

protected long socket
Underlying socket.


outputStreamOutputBuffer

protected OutputBuffer outputStreamOutputBuffer
Underlying output buffer.


filterLibrary

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


activeFilters

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


lastActiveFilter

protected int lastActiveFilter
Index of the last active filter.


bbuf

protected java.nio.ByteBuffer bbuf
Direct byte buffer used for writing.

Constructor Detail

InternalAprOutputBuffer

public InternalAprOutputBuffer(Response response)
Default constructor.


InternalAprOutputBuffer

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

Method Detail

setSocket

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


getSocket

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


setSocketBuffer

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


addFilter

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


getFilters

public OutputFilter[] getFilters()
Get filters.


clearFilters

public void clearFilters()
Clear filters.


addActiveFilter

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


flush

public void flush()
           throws java.io.IOException
Flush the response.

Throws:
java.io.IOException - an undelying I/O error occured

reset

public void reset()
Reset current response.

Throws:
java.lang.IllegalStateException - if the response has already been committed

recycle

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


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.


endRequest

public void endRequest()
                throws java.io.IOException
End request.

Throws:
java.io.IOException - an undelying I/O error occured

sendAck

public void sendAck()
             throws java.io.IOException
Send an acknoledgement.

Throws:
java.io.IOException

sendStatus

public void sendStatus()
Send the response status line.


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(java.lang.String name,
                       java.lang.String value)
Send a header.

Parameters:
name - Header name
value - Header value

endHeaders

public void endHeaders()
End the header block.


doWrite

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

Specified by:
doWrite in interface OutputBuffer
Parameters:
chunk - byte chunk
res - used to allow buffers that can be shared by multiple responses.
Returns:
number of bytes written
Throws:
java.io.IOException - an undelying I/O error occured

commit

protected void commit()
               throws java.io.IOException
Commit the response.

Throws:
java.io.IOException - an undelying I/O error occured

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(java.lang.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

flushBuffer

protected void flushBuffer()
                    throws java.io.IOException
Callback to write data from the buffer.

Throws:
java.io.IOException

Apache Tomcat 6.0.53

Copyright © 2000-2017 Apache Software Foundation. All Rights Reserved.