|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.weborganic.bastille.cache.util.GZIPUtils
public final class GZIPUtils
A utility class for GZIP compression.
Method Summary | |
---|---|
static void |
addGzipHeader(javax.servlet.http.HttpServletResponse res)
Adds the gzip HTTP header to the response to indicates to clients that the response body is compressed. |
static byte[] |
gzip(byte[] ungzipped)
Gzip the specified content. |
static boolean |
isGzipped(byte[] candidate)
Checks the first two bytes of the candidate byte array for the magic number 0x677a. |
static boolean |
shouldGzippedBodyBeZero(byte[] compressed)
Checks whether a gzipped body is actually empty and should just be zero. |
static byte[] |
ungzip(byte[] gzipped)
A highly performant ungzip implementation. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static boolean isGzipped(byte[] candidate)
This magic number was obtained from /usr/share/file/magic. The line for gzip is:
>>14 beshort 0x677a (gzipped)
candidate
- the byte array to check
true
if gzipped;
false
if null
, less than two bytes or not gzipped.public static boolean shouldGzippedBodyBeZero(byte[] compressed)
When the compressedBytes is EMPTY_GZIPPED_CONTENT_SIZE
it should be zero.
compressed
- the gzipped response body
true
if the response should be 0, even if it is isn't.public static void addGzipHeader(javax.servlet.http.HttpServletResponse res) throws javax.servlet.ServletException
This method checks that the header has actually been included.
res
- the response which will have a header added to it
javax.servlet.ServletException
- if the response is committed or set header is ignored.public static byte[] gzip(byte[] ungzipped) throws IOException
ungzipped
- the bytes to be gzipped
IOException
- the content was already compressed.public static byte[] ungzip(byte[] gzipped) throws IOException
gzipped
- the gzipped content
IOException
- Should an error occur while ungzipping the content
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |