Package spark.utils

Class GzipUtils

java.lang.Object
spark.utils.GzipUtils

public class GzipUtils extends Object
GZIP utility class.
  • Field Details

  • 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 a GZIPOutputStream.
      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:
      IOException - in case of IO error.
    • addContentEncodingHeaderIfMissing

      private static void addContentEncodingHeaderIfMissing(javax.servlet.http.HttpServletResponse response, boolean wantsGzip)