All Packages Class Hierarchy This Package Previous Next Index
java.lang.Object | +----java.io.OutputStream | +----java.io.FilterOutputStream | +----java.io.BufferedOutputStream | +----Acme.Serve.servlet.http.ChunkedOutputStream
This class lets a Servlet send its response data as an HTTP/1.1 chunked stream. Chunked streams are a way to send arbitrary-length data without having to know beforehand how much you're going to send. They are introduced by a "Transfer-Encoding: chunked" header, so you have to set that header when you make one of these streams.
Sample usage:
res.setHeader( "Transfer-Encoding", "chunked" ); OutputStream out = res.getOutputStream(); ChunkedOutputStream chunkOut = new ChunkedOutputStream( out ); (write data to chunkOut instead of out) (optionally set footers) chunkOut.done();
Every time the stream gets flushed, a chunk is sent. When done() is called, an empty chunk is sent, marking the end of the chunked stream as per the chunking spec.
Fetch the software.
Fetch the entire Acme package.
public ChunkedOutputStream(OutputStream out)
public ChunkedOutputStream(OutputStream out, int size)
public synchronized void flush() throws IOException
public void setFooter(String name, String value)
public void done() throws IOException
public void close() throws IOException
public synchronized void write(byte b[], int off, int len) throws IOException
The only reason we have to override the BufferedOutputStream version of this is that it writes the array directly to the output stream if doesn't fit in the buffer. So we make it use our own chunk-write routine instead. Otherwise this is identical to the parent-class version.
All Packages Class Hierarchy This Package Previous Next Index
ACME Java ACME Labs