Class CompressionResponseStream
java.lang.Object
java.io.OutputStream
jakarta.servlet.ServletOutputStream
org.jumpmind.symmetric.web.compression.CompressionResponseStream
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
public class CompressionResponseStream
extends jakarta.servlet.ServletOutputStream
Implementation of ServletOutputStream that works with the CompressionServletResponseWrapper implementation.
This package is derived from the Jakarta Tomcat examples compression filter and is distributed in SymmetricDS
for convenience.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected boolean
Has this stream been closed?protected OutputStream
The underlying gzip output stream to which we should write data.protected jakarta.servlet.http.HttpServletResponse
The response with which this servlet output stream is associated. -
Constructor Summary
ConstructorsConstructorDescriptionCompressionResponseStream
(jakarta.servlet.http.HttpServletResponse response, int compressionLevel, int compressionStrategy) Construct a servlet output stream associated with the specified Response. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Close this output stream, causing any buffered data to be flushed and any further output data to throw an IOException.boolean
closed()
Has this response stream been closed?void
flush()
Flush any buffered data for this output stream, which also causes the response to be committed.boolean
isReady()
void
setWriteListener
(jakarta.servlet.WriteListener writeListener) void
write
(byte[] b) Writeb.length
bytes from the specified byte array to our output stream.void
write
(byte[] b, int off, int len) Writelen
bytes from the specified byte array, starting at the specified offset, to our output stream.void
write
(int b) Write the specified byte to our output stream.Methods inherited from class jakarta.servlet.ServletOutputStream
print, print, print, print, print, print, print, println, println, println, println, println, println, println, println
Methods inherited from class java.io.OutputStream
nullOutputStream
-
Field Details
-
gzipstream
The underlying gzip output stream to which we should write data. -
closed
protected boolean closedHas this stream been closed? -
response
protected jakarta.servlet.http.HttpServletResponse responseThe response with which this servlet output stream is associated.
-
-
Constructor Details
-
CompressionResponseStream
public CompressionResponseStream(jakarta.servlet.http.HttpServletResponse response, int compressionLevel, int compressionStrategy) throws IOException Construct a servlet output stream associated with the specified Response.- Parameters:
response
- The associated response- Throws:
IOException
-
-
Method Details
-
close
Close this output stream, causing any buffered data to be flushed and any further output data to throw an IOException.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classOutputStream
- Throws:
IOException
-
flush
Flush any buffered data for this output stream, which also causes the response to be committed.- Specified by:
flush
in interfaceFlushable
- Overrides:
flush
in classOutputStream
- Throws:
IOException
-
write
Write the specified byte to our output stream.- Specified by:
write
in classOutputStream
- Parameters:
b
- The byte to be written- Throws:
IOException
- if an input/output error occurs
-
write
Writeb.length
bytes from the specified byte array to our output stream.- Overrides:
write
in classOutputStream
- Parameters:
b
- The byte array to be written- Throws:
IOException
- if an input/output error occurs
-
write
Writelen
bytes from the specified byte array, starting at the specified offset, to our output stream.- Overrides:
write
in classOutputStream
- Parameters:
b
- The byte array containing the bytes to be writtenoff
- Zero-relative starting offset of the bytes to be writtenlen
- The number of bytes to be written- Throws:
IOException
- if an input/output error occurs
-
isReady
public boolean isReady()- Specified by:
isReady
in classjakarta.servlet.ServletOutputStream
-
closed
public boolean closed()Has this response stream been closed? -
setWriteListener
public void setWriteListener(jakarta.servlet.WriteListener writeListener) - Specified by:
setWriteListener
in classjakarta.servlet.ServletOutputStream
-