|
|||||||||
| Home >> All >> org >> mortbay >> [ http overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.mortbay.http
Class HttpOutputStream

java.lang.Objectjava.io.OutputStream
java.io.FilterOutputStream
org.mortbay.http.HttpOutputStream
- All Implemented Interfaces:
- HttpMessage.HeaderWriter, org.mortbay.util.OutputObserver
- public class HttpOutputStream
- extends java.io.FilterOutputStream
- implements org.mortbay.util.OutputObserver, HttpMessage.HeaderWriter
- extends java.io.FilterOutputStream
HTTP Http OutputStream. Acts as a BufferedOutputStream until setChunking() is called. Once chunking is enabled, the raw stream is chunk encoded as per RFC2616. Implements the following HTTP and Servlet features:
- Filters for content and transfer encodings.
- Allows output to be reset if not committed (buffer never flushed).
- Notification of significant output events for filter triggering, header flushing, etc.
- Version:
- $Id: HttpOutputStream.java,v 1.20 2003/10/05 23:46:20 gregwilkins Exp $
| Nested Class Summary | |
private class |
HttpOutputStream.HttpWriter
|
| Field Summary | |
(package private) static int |
__BUFFER_SIZE
|
(package private) static byte[] |
__CHUNK_EOF_B
|
(package private) static java.lang.String |
__CRLF
|
(package private) static byte[] |
__CRLF_B
|
static java.lang.Class[] |
__filterArg
|
(package private) static int |
__FIRST_RESERVE
|
private BufferedOutputStream |
_bufferedOut
|
private boolean |
_bufferHeaders
|
private int |
_bufferSize
|
(package private) int |
_bytes
|
private ChunkingOutputStream |
_chunkingOut
|
(package private) boolean |
_closing
|
private HttpMessage.HeaderWriter |
_headerOut
|
private int |
_headerReserve
|
private HttpOutputStream.HttpWriter |
_iso8859writer
|
private NullableOutputStream |
_nullableOut
|
private java.util.ArrayList |
_observers
|
private java.io.OutputStream |
_realOut
|
private HttpOutputStream.HttpWriter |
_utf8writer
|
private boolean |
_written
|
private static org.apache.commons.logging.Log |
log
|
| Fields inherited from class java.io.FilterOutputStream |
out |
| Fields inherited from interface org.mortbay.util.OutputObserver |
__CLOSED, __CLOSING, __COMMITING, __FIRST_WRITE, __RESET_BUFFER |
| Constructor Summary | |
HttpOutputStream(java.io.OutputStream outputStream)
Constructor. |
|
HttpOutputStream(java.io.OutputStream outputStream,
int bufferSize)
Constructor. |
|
HttpOutputStream(java.io.OutputStream outputStream,
int bufferSize,
int headerReserve)
Constructor. |
|
| Method Summary | |
void |
addObserver(org.mortbay.util.OutputObserver observer)
Add an Output Observer. |
void |
addObserver(org.mortbay.util.OutputObserver observer,
java.lang.Object data)
Add an Output Observer. |
void |
close()
Close the stream. |
void |
destroy()
|
void |
flush()
This method attempt to flush all buffered output to be written to the underlying output sink. |
int |
getBufferSize()
Get the output buffer capacity. |
int |
getBytesWritten()
|
java.io.OutputStream |
getFilterStream()
Get Filter OutputStream. |
private java.io.Writer |
getISO8859Writer()
|
java.io.OutputStream |
getOutputStream()
Get the backing output stream. |
private java.io.Writer |
getUTF8Writer()
|
java.io.Writer |
getWriter(java.lang.String encoding)
|
boolean |
isChunking()
Get chunking mode |
boolean |
isClosed()
Close the stream. |
boolean |
isNullOutput()
is the output Nulled? |
boolean |
isWritten()
Has any data been written to the stream. |
private void |
notify(int action)
|
void |
nullOutput()
Null the output. |
void |
outputNotify(java.io.OutputStream out,
int action,
java.lang.Object ignoredData)
Output Notification. |
protected void |
prepareOutput()
|
void |
resetBuffer()
Reset Buffered output. |
void |
resetObservers()
Reset the observers. |
void |
resetStream()
Reset the stream. |
void |
setBufferedOutputStream(BufferedOutputStream bos,
boolean bufferHeaders)
|
void |
setBufferSize(int size)
Set the output buffer size. |
void |
setChunking()
Set chunking mode. |
void |
setFilterStream(java.io.OutputStream filter)
Set Filter OutputStream. |
void |
setTrailer(HttpFields trailer)
Set the trailer to send with a chunked close. |
java.lang.String |
toString()
Convert this Object to a human-readable String. |
void |
write(byte[] b)
This method writes all the bytes in the specified array to the underlying OutputStream. |
void |
write(byte[] b,
int off,
int len)
This method calls the write(int) method len
times for all bytes from the array buf starting at index
offset. |
void |
write(java.io.InputStream in,
int len)
|
void |
write(int b)
This method writes a single byte of output to the underlying OutputStream. |
void |
writeHeader(HttpMessage httpMessage)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
log
private static org.apache.commons.logging.Log log
__CRLF
static final java.lang.String __CRLF
- See Also:
- Constant Field Values
__CRLF_B
static final byte[] __CRLF_B
__CHUNK_EOF_B
static final byte[] __CHUNK_EOF_B
__BUFFER_SIZE
static final int __BUFFER_SIZE
- See Also:
- Constant Field Values
__FIRST_RESERVE
static final int __FIRST_RESERVE
- See Also:
- Constant Field Values
__filterArg
public static final java.lang.Class[] __filterArg
_realOut
private java.io.OutputStream _realOut
_nullableOut
private NullableOutputStream _nullableOut
_headerOut
private HttpMessage.HeaderWriter _headerOut
_bufferedOut
private BufferedOutputStream _bufferedOut
_chunkingOut
private ChunkingOutputStream _chunkingOut
_written
private boolean _written
_observers
private java.util.ArrayList _observers
_bufferSize
private int _bufferSize
_headerReserve
private int _headerReserve
_bufferHeaders
private boolean _bufferHeaders
_iso8859writer
private HttpOutputStream.HttpWriter _iso8859writer
_utf8writer
private HttpOutputStream.HttpWriter _utf8writer
_bytes
int _bytes
_closing
boolean _closing
| Constructor Detail |
HttpOutputStream
public HttpOutputStream(java.io.OutputStream outputStream)
- Constructor.
HttpOutputStream
public HttpOutputStream(java.io.OutputStream outputStream, int bufferSize)
- Constructor.
HttpOutputStream
public HttpOutputStream(java.io.OutputStream outputStream, int bufferSize, int headerReserve)
- Constructor.
| Method Detail |
setBufferedOutputStream
public void setBufferedOutputStream(BufferedOutputStream bos, boolean bufferHeaders)
getOutputStream
public java.io.OutputStream getOutputStream()
- Get the backing output stream.
A stream without filters or chunking is returned.
getFilterStream
public java.io.OutputStream getFilterStream()
- Get Filter OutputStream.
Get the current top of the OutputStream filter stack
setFilterStream
public void setFilterStream(java.io.OutputStream filter)
- Set Filter OutputStream.
Set output filter stream, which should be constructed to wrap
the stream returned from get FilterStream.
isWritten
public boolean isWritten()
- Has any data been written to the stream.
getBufferSize
public int getBufferSize()
- Get the output buffer capacity.
setBufferSize
public void setBufferSize(int size)
throws java.lang.IllegalStateException
- Set the output buffer size.
Note that this is the minimal buffer size and that installed
filters may perform their own buffering and are likely to change
the size of the output. Also the pre and post reserve buffers may be
allocated within the buffer for headers and chunking.
getBytesWritten
public int getBytesWritten()
resetBuffer
public void resetBuffer()
throws java.lang.IllegalStateException
- Reset Buffered output.
If no data has been committed, the buffer output is discarded and
the filters may be reinitialized.
addObserver
public void addObserver(org.mortbay.util.OutputObserver observer)
- Add an Output Observer.
Output Observers get notified of significant events on the
output stream. Observers are called in the reverse order they
were added.
They are removed when the stream is closed.
addObserver
public void addObserver(org.mortbay.util.OutputObserver observer, java.lang.Object data)
- Add an Output Observer.
Output Observers get notified of significant events on the
output stream. Observers are called in the reverse order they
were added.
They are removed when the stream is closed.
resetObservers
public void resetObservers()
- Reset the observers.
nullOutput
public void nullOutput()
throws java.io.IOException
- Null the output.
All output written is discarded until the stream is reset. Used
for HEAD requests.
isNullOutput
public boolean isNullOutput()
throws java.io.IOException
- is the output Nulled?
setChunking
public void setChunking()
- Set chunking mode.
isChunking
public boolean isChunking()
- Get chunking mode
resetStream
public void resetStream()
throws java.io.IOException,
java.lang.IllegalStateException
- Reset the stream.
Turn disable all filters.
destroy
public void destroy()
setTrailer
public void setTrailer(HttpFields trailer)
- Set the trailer to send with a chunked close.
writeHeader
public void writeHeader(HttpMessage httpMessage) throws java.io.IOException
- Specified by:
writeHeaderin interfaceHttpMessage.HeaderWriter
write
public void write(int b)
throws java.io.IOException
- Description copied from class:
java.io.FilterOutputStream - This method writes a single byte of output to the underlying
OutputStream.
write
public void write(byte[] b)
throws java.io.IOException
- Description copied from class:
java.io.FilterOutputStream - This method writes all the bytes in the specified array to the underlying
OutputStream. It does this by calling the three parameter version of this method -write(byte[], int, int)in this class instead of writing to the underlyingOutputStreamdirectly. This allows most subclasses to avoid overriding this method.
write
public void write(byte[] b,
int off,
int len)
throws java.io.IOException
- Description copied from class:
java.io.FilterOutputStream - This method calls the
write(int)methodlentimes for all bytes from the arraybufstarting at indexoffset. Subclasses should overwrite this method to get a more efficient implementation.
prepareOutput
protected void prepareOutput()
throws java.io.IOException
flush
public void flush()
throws java.io.IOException
- Description copied from class:
java.io.FilterOutputStream - This method attempt to flush all buffered output to be written to the
underlying output sink.
isClosed
public boolean isClosed()
throws java.io.IOException
- Close the stream.
close
public void close()
throws java.io.IOException
- Close the stream.
outputNotify
public void outputNotify(java.io.OutputStream out, int action, java.lang.Object ignoredData) throws java.io.IOException
- Output Notification.
Called by the internal Buffered Output and the event is passed on to
this streams observers.
- Specified by:
outputNotifyin interfaceorg.mortbay.util.OutputObserver
notify
private void notify(int action)
throws java.io.IOException
write
public void write(java.io.InputStream in, int len) throws java.io.IOException
getISO8859Writer
private java.io.Writer getISO8859Writer() throws java.io.IOException
getUTF8Writer
private java.io.Writer getUTF8Writer() throws java.io.IOException
getWriter
public java.io.Writer getWriter(java.lang.String encoding) throws java.io.IOException
toString
public java.lang.String toString()
- Description copied from class:
java.lang.Object - Convert this Object to a human-readable String.
There are no limits placed on how long this String
should be or what it should contain. We suggest you
make it as intuitive as possible to be able to place
it into System.out.println() 55
and such.
It is typical, but not required, to ensure that this method never completes abruptly with a java.lang.RuntimeException.
This method will be called when performing string concatenation with this object. If the result is
null, string concatenation will instead use"null".The default implementation returns
getClass().getName() + "@" + Integer.toHexString(hashCode()).
|
|||||||||
| Home >> All >> org >> mortbay >> [ http overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC