Package spark.utils
Class GzipUtils
- java.lang.Object
-
- spark.utils.GzipUtils
-
public class GzipUtils extends java.lang.Object
GZIP utility class.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
GzipUtils.StringMatch
Used instead of lambdas due to risk for java.lang.IncompatibleClassChangeError.
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String
ACCEPT_ENCODING
private static java.lang.String
CONTENT_ENCODING
private static java.lang.String
GZIP
private static GzipUtils.StringMatch
STRING_MATCH
-
Constructor Summary
Constructors Modifier Constructor Description private
GzipUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static void
addContentEncodingHeaderIfMissing(javax.servlet.http.HttpServletResponse response, boolean wantsGzip)
static java.io.OutputStream
checkAndWrap(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.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
GZIPOutputStream
otherwise 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)
-
-