org.eclipse.jetty.http.gzip
Class GzipStream

java.lang.Object
  extended by java.io.OutputStream
      extended by javax.servlet.ServletOutputStream
          extended by org.eclipse.jetty.http.gzip.GzipStream
All Implemented Interfaces:
Closeable, Flushable
Direct Known Subclasses:
IncludableGzipFilter.IncludableGzipStream

public class GzipStream
extends ServletOutputStream


Field Summary
protected  ByteArrayOutputStream2 _bOut
           
protected  int _bufferSize
           
protected  boolean _closed
           
protected  long _contentLength
           
protected  GZIPOutputStream _gzOut
           
protected  int _minGzipSize
           
protected  OutputStream _out
           
protected  HttpServletRequest _request
           
protected  HttpServletResponse _response
           
 
Constructor Summary
GzipStream(HttpServletRequest request, HttpServletResponse response, long contentLength, int bufferSize, int minGzipSize)
          Instantiates a new gzip stream.
 
Method Summary
 void close()
           
 void doGzip()
          Do gzip.
 void doNotGzip()
          Do not gzip.
 void finish()
          Finish.
 void flush()
           
protected  PrintWriter newWriter(OutputStream out, String encoding)
          Allows derived implementations to replace PrintWriter implementation.
 void resetBuffer()
          Reset buffer.
protected  boolean setContentEncodingGzip()
          Sets the content encoding gzip.
 void setContentLength(long length)
          Sets the content length.
 void write(byte[] b)
           
 void write(byte[] b, int off, int len)
           
 void write(int b)
           
 
Methods inherited from class javax.servlet.ServletOutputStream
print, print, print, print, print, print, print, println, println, println, println, println, println, println, println
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_request

protected HttpServletRequest _request

_response

protected HttpServletResponse _response

_out

protected OutputStream _out

_bOut

protected ByteArrayOutputStream2 _bOut

_gzOut

protected GZIPOutputStream _gzOut

_closed

protected boolean _closed

_bufferSize

protected int _bufferSize

_minGzipSize

protected int _minGzipSize

_contentLength

protected long _contentLength
Constructor Detail

GzipStream

public GzipStream(HttpServletRequest request,
                  HttpServletResponse response,
                  long contentLength,
                  int bufferSize,
                  int minGzipSize)
           throws IOException
Instantiates a new gzip stream.

Parameters:
request - the request
response - the response
contentLength - the content length
bufferSize - the buffer size
minGzipSize - the min gzip size
Throws:
IOException - Signals that an I/O exception has occurred.
Method Detail

resetBuffer

public void resetBuffer()
Reset buffer.


setContentLength

public void setContentLength(long length)
Sets the content length.

Parameters:
length - the new content length

flush

public void flush()
           throws IOException
Specified by:
flush in interface Flushable
Overrides:
flush in class OutputStream
Throws:
IOException
See Also:
OutputStream.flush()

close

public void close()
           throws IOException
Specified by:
close in interface Closeable
Overrides:
close in class OutputStream
Throws:
IOException
See Also:
OutputStream.close()

finish

public void finish()
            throws IOException
Finish.

Throws:
IOException - Signals that an I/O exception has occurred.

write

public void write(int b)
           throws IOException
Specified by:
write in class OutputStream
Throws:
IOException
See Also:
OutputStream.write(int)

write

public void write(byte[] b)
           throws IOException
Overrides:
write in class OutputStream
Throws:
IOException
See Also:
OutputStream.write(byte[])

write

public void write(byte[] b,
                  int off,
                  int len)
           throws IOException
Overrides:
write in class OutputStream
Throws:
IOException
See Also:
OutputStream.write(byte[], int, int)

setContentEncodingGzip

protected boolean setContentEncodingGzip()
Sets the content encoding gzip.

Returns:
true, if successful

doGzip

public void doGzip()
            throws IOException
Do gzip.

Throws:
IOException - Signals that an I/O exception has occurred.

doNotGzip

public void doNotGzip()
               throws IOException
Do not gzip.

Throws:
IOException - Signals that an I/O exception has occurred.

newWriter

protected PrintWriter newWriter(OutputStream out,
                                String encoding)
                         throws UnsupportedEncodingException
Allows derived implementations to replace PrintWriter implementation.

Throws:
UnsupportedEncodingException


Copyright © 1995-2011 Mort Bay Consulting. All Rights Reserved.