类 ShallowEtagHeaderFilter

    • 方法详细资料

      • setWriteWeakETag

        public void setWriteWeakETag​(boolean writeWeakETag)
        Set whether the ETag value written to the response should be weak, as per RFC 7232.

        Should be configured using an <init-param> for parameter name "writeWeakETag" in the filter definition in web.xml.

        从以下版本开始:
        4.3
        另请参阅:
        RFC 7232 section 2.3
      • isWriteWeakETag

        public boolean isWriteWeakETag()
        Return whether the ETag value written to the response should be weak, as per RFC 7232.
        从以下版本开始:
        4.3
      • isEligibleForEtag

        protected boolean isEligibleForEtag​(HttpServletRequest request,
                                            HttpServletResponse response,
                                            int responseStatusCode,
                                            InputStream inputStream)
        Indicates whether the given request and response are eligible for ETag generation.

        The default implementation returns true if all conditions match:

        • response status codes in the 2xx series
        • request method is a GET
        • response Cache-Control header is not set or does not contain a "no-store" directive
        参数:
        request - the HTTP request
        response - the HTTP response
        responseStatusCode - the HTTP response status code
        inputStream - the response body
        返回:
        true if eligible for ETag generation, false otherwise
      • generateETagHeaderValue

        protected String generateETagHeaderValue​(InputStream inputStream,
                                                 boolean isWeak)
                                          throws IOException
        Generate the ETag header value from the given response body byte array.

        The default implementation generates an MD5 hash.

        参数:
        inputStream - the response body as an InputStream
        isWeak - whether the generated ETag should be weak
        返回:
        the ETag header value
        抛出:
        IOException
        另请参阅:
        DigestUtils
      • disableContentCaching

        public static void disableContentCaching​(ServletRequest request)
        This method can be used to disable the content caching response wrapper of the ShallowEtagHeaderFilter. This can be done before the start of HTTP streaming for example where the response will be written to asynchronously and not in the context of a Servlet container thread.
        从以下版本开始:
        4.2