Class GZipResponseUtil
java.lang.Object
com.erudika.para.server.utils.GZipResponseUtil
A collection of response processing utilities, which are shared between 2 or more filters.
- Version:
- $Id: ResponseUtil.java 744 2008-08-16 20:10:49Z gregluck $
- Author:
- Greg Luck
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddGzipHeader(jakarta.servlet.http.HttpServletResponse response) Adds the gzip HTTP header to the response.static voidAdds the Vary: Accept-Encoding header to the response if needed.static booleanshouldBodyBeZero(jakarta.servlet.http.HttpServletRequest request, int responseStatus) Performs a number of checks to ensure response saneness according to the rules of RFC2616: If the response code isHttpServletResponse.SC_NO_CONTENTthen it is illegal for the body to contain anything.static booleanshouldGzippedBodyBeZero(byte[] compressedBytes, jakarta.servlet.http.HttpServletRequest request) Checks whether a gzipped body is actually empty and should just be zero.
-
Method Details
-
shouldGzippedBodyBeZero
public static boolean shouldGzippedBodyBeZero(byte[] compressedBytes, jakarta.servlet.http.HttpServletRequest request) Checks whether a gzipped body is actually empty and should just be zero. When the compressedBytes isEMPTY_GZIPPED_CONTENT_SIZEit should be zero.- Parameters:
compressedBytes- the gzipped response bodyrequest- the client HTTP request- Returns:
- true if the response should be 0, even if it is isn't.
-
shouldBodyBeZero
public static boolean shouldBodyBeZero(jakarta.servlet.http.HttpServletRequest request, int responseStatus) Performs a number of checks to ensure response saneness according to the rules of RFC2616:- If the response code is
HttpServletResponse.SC_NO_CONTENTthen it is illegal for the body to contain anything. See http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.5 - If the response code is
HttpServletResponse.SC_NOT_MODIFIEDthen it is illegal for the body to contain anything. See http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.5
- Parameters:
request- the client HTTP requestresponseStatus- the responseStatus- Returns:
- true if the response should be 0, even if it is isn't.
- If the response code is
-
addGzipHeader
public static void addGzipHeader(jakarta.servlet.http.HttpServletResponse response) throws jakarta.servlet.ServletException Adds the gzip HTTP header to the response. This is needed when a gzipped body is returned so that browsers can properly decompress it.- Parameters:
response- the response which will have a header added to it. I.e this method changes its parameter- Throws:
jakarta.servlet.ServletException- Either the response is committed or we were called using the include method from aRequestDispatcher.include(jakarta.servlet.ServletRequest, jakarta.servlet.ServletResponse)method and the set header is ignored.
-
addVaryAcceptEncoding
Adds the Vary: Accept-Encoding header to the response if needed.- Parameters:
wrapper- response
-