Package spark.utils
Class GzipUtils
java.lang.Object
spark.utils.GzipUtils
GZIP utility class.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classUsed instead of lambdas due to risk for java.lang.IncompatibleClassChangeError. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Stringprivate static final Stringprivate static final Stringprivate static final GzipUtils.StringMatch -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static voidaddContentEncodingHeaderIfMissing(javax.servlet.http.HttpServletResponse response, boolean wantsGzip) static 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 Details
-
ACCEPT_ENCODING
- See Also:
-
CONTENT_ENCODING
- See Also:
-
GZIP
- See Also:
-
STRING_MATCH
-
-
Constructor Details
-
GzipUtils
private GzipUtils()
-
-
Method Details
-
checkAndWrap
public static OutputStream checkAndWrap(javax.servlet.http.HttpServletRequest httpRequest, javax.servlet.http.HttpServletResponse httpResponse, boolean requireWantsHeader) throws IOException Checks 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:
IOException- in case of IO error.
-
addContentEncodingHeaderIfMissing
private static void addContentEncodingHeaderIfMissing(javax.servlet.http.HttpServletResponse response, boolean wantsGzip)
-