Package spark.utils
Class GzipUtils
- java.lang.Object
-
- spark.utils.GzipUtils
-
public class GzipUtils extends java.lang.ObjectGZIP utility class.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classGzipUtils.StringMatchUsed instead of lambdas due to risk for java.lang.IncompatibleClassChangeError.
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.StringACCEPT_ENCODINGprivate static java.lang.StringCONTENT_ENCODINGprivate static java.lang.StringGZIPprivate static GzipUtils.StringMatchSTRING_MATCH
-
Constructor Summary
Constructors Modifier Constructor Description privateGzipUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static voidaddContentEncodingHeaderIfMissing(javax.servlet.http.HttpServletResponse response, boolean wantsGzip)static java.io.OutputStreamcheckAndWrap(javax.servlet.http.HttpServletRequest httpRequest, javax.servlet.http.HttpServletResponse httpResponse, boolean requireWantsHeader)Checks if the HTTP request/response accepts and wants GZIP and i that case wraps the response output stream in aGZIPOutputStream.
-
-
-
Field Detail
-
ACCEPT_ENCODING
private static final java.lang.String ACCEPT_ENCODING
- See Also:
- Constant Field Values
-
CONTENT_ENCODING
private static final java.lang.String CONTENT_ENCODING
- See Also:
- Constant Field Values
-
GZIP
private static final java.lang.String GZIP
- See Also:
- Constant Field Values
-
STRING_MATCH
private static final GzipUtils.StringMatch STRING_MATCH
-
-
Method Detail
-
checkAndWrap
public static java.io.OutputStream checkAndWrap(javax.servlet.http.HttpServletRequest httpRequest, javax.servlet.http.HttpServletResponse httpResponse, boolean requireWantsHeader) throws java.io.IOExceptionChecks if the HTTP request/response accepts and wants GZIP and i that case wraps the response output stream in aGZIPOutputStream.- Parameters:
httpRequest- the HTTP servlet request.httpResponse- the HTTP servlet response.requireWantsHeader- if wants header is required- Returns:
- if accepted and wanted a
GZIPOutputStreamotherwise the unchanged response output stream. - Throws:
java.io.IOException- in case of IO error.
-
addContentEncodingHeaderIfMissing
private static void addContentEncodingHeaderIfMissing(javax.servlet.http.HttpServletResponse response, boolean wantsGzip)
-
-