Package spark.utils

Class 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.
    • 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 a GZIPOutputStream.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • GzipUtils

        private GzipUtils()
    • 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 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:
        java.io.IOException - in case of IO error.
      • addContentEncodingHeaderIfMissing

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