FileDocCategorySizeDatePackage
GzipOutputFilter.javaAPI DocGlassfish v2 API6002Fri May 04 22:32:42 BST 2007org.apache.coyote.http11.filters

GzipOutputFilter

public class GzipOutputFilter extends Object implements org.apache.coyote.http11.OutputFilter
Gzip output filter.
author
Remy Maucherat

Fields Summary
protected static final String
ENCODING_NAME
protected static final org.apache.tomcat.util.buf.ByteChunk
ENCODING
protected org.apache.coyote.OutputBuffer
buffer
Next buffer in the pipeline.
protected GZIPOutputStream
compressionStream
Compression output stream.
protected OutputStream
fakeOutputStream
Fake internal output stream.
Constructors Summary
Methods Summary
public intdoWrite(org.apache.tomcat.util.buf.ByteChunk chunk, org.apache.coyote.Response res)
Write some bytes.

return
number of bytes written by the filter



    // --------------------------------------------------- OutputBuffer Methods


                     
         
          
        if (compressionStream == null) {
            compressionStream = new GZIPOutputStream(fakeOutputStream);
        }
        compressionStream.write(chunk.getBytes(), chunk.getStart(), 
                                chunk.getLength());
        return chunk.getLength();
    
public longend()
End the current request. It is acceptable to write extra bytes using buffer.doWrite during the execution of this method.

        if (compressionStream == null) {
            compressionStream = new GZIPOutputStream(fakeOutputStream);
        }
        compressionStream.finish();
        return ((OutputFilter) buffer).end();
    
public org.apache.tomcat.util.buf.ByteChunkgetEncodingName()
Return the name of the associated encoding; Here, the value is "identity".

        return ENCODING;
    
public voidrecycle()
Make the filter ready to process the next request.

        // Set compression stream to null
        compressionStream = null;
    
public voidsetBuffer(org.apache.coyote.OutputBuffer buffer)
Set the next buffer in the filter pipeline.

        this.buffer = buffer;
    
public voidsetResponse(org.apache.coyote.Response response)
Some filters need additional parameters from the response. All the necessary reading can occur in that method, as this method is called after the response header processing is complete.