Package com.google.gwt.user.server.rpc
Class LazyGzipCompressingOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- java.io.FilterOutputStream
-
- com.google.gwt.user.server.rpc.LazyGzipCompressingOutputStream
-
- All Implemented Interfaces:
java.io.Closeable,java.io.Flushable,java.lang.AutoCloseable
public class LazyGzipCompressingOutputStream extends java.io.FilterOutputStreamA filter output stream for anHttpServletResponse'soutput streamwhich starts out by writing to a size-limitedbytebuffer and defers the decision of whether or not to use GZIP compression to the point where the content written to it exceeds the buffer size or the stream isflushedorclosed. If the stream isclosedbefore the buffer size is exceeded, the buffer is written to theHttpServletResponse'soutput streamwithout compression activated. If the stream isflushedbefore compression was activated, the buffer content is flushed to the response's output stream, the buffer is released, and compression will not be activated for this stream ever.Flushingthe stream after compression has been activated will delegate to theGZIPOutputStream'sflushmethod.The stream is not thread-safe. Multiple threads trying to write to it concurrently may end up in a race condition, may overwrite buffer content and may cause inconsistencies when crossing the size threshold for compression.
-
-
Constructor Summary
Constructors Constructor Description LazyGzipCompressingOutputStream(javax.servlet.http.HttpServletResponse response, int sizeLimitForNoCompression)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()voidflush()voidwrite(byte[] b, int off, int len)voidwrite(int b)
-
-
-
Method Detail
-
write
public void write(int b) throws java.io.IOException- Overrides:
writein classjava.io.FilterOutputStream- Throws:
java.io.IOException
-
write
public void write(byte[] b, int off, int len) throws java.io.IOException- Overrides:
writein classjava.io.FilterOutputStream- Throws:
java.io.IOException
-
flush
public void flush() throws java.io.IOException- Specified by:
flushin interfacejava.io.Flushable- Overrides:
flushin classjava.io.FilterOutputStream- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classjava.io.FilterOutputStream- Throws:
java.io.IOException
-
-