org.apache.solr.servlet.cache

## Class HttpCacheHeaderUtil

- java.lang.Object
- - org.apache.solr.servlet.cache.HttpCacheHeaderUtil

-     public final class HttpCacheHeaderUtil
      extends Object

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `HttpCacheHeaderUtil()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static String` | `calcEtag(SolrQueryRequest solrReq)` Calculates a tag for the ETag header.
    `static long` | `calcLastModified(SolrQueryRequest solrReq)` Calculate the appropriate last-modified time for Solr relative the current request.
    `static boolean` | `checkETagValidators(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp, Method reqMethod, String etag)` Check for etag related conditional headers and set status
    `static void` | `checkHttpCachingVeto(SolrQueryResponse solrRsp, javax.servlet.http.HttpServletResponse resp, Method reqMethod)` Checks if the downstream request handler wants to avoid HTTP caching of the response.
    `static boolean` | `checkLastModValidators(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp, long lastMod)` Check for modify time related conditional headers and set status
    `static boolean` | `doCacheHeaderValidation(SolrQueryRequest solrReq, javax.servlet.http.HttpServletRequest req, Method reqMethod, javax.servlet.http.HttpServletResponse resp)` Sets HTTP Response cache validator headers appropriately and validates the HTTP Request against these using any conditional request headers.
    `static boolean` | `isMatchingEtag(List<String> headerList, String etag)` Checks if one of the tags in the list equals the given etag.
    `static void` | `sendNotModified(javax.servlet.http.HttpServletResponse res)`
    `static void` | `sendPreconditionFailed(javax.servlet.http.HttpServletResponse res)`
    `static void` | `setCacheControlHeader(SolrConfig conf, javax.servlet.http.HttpServletResponse resp, Method method)` Set the Cache-Control HTTP header (and Expires if needed) based on the SolrConfig.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### HttpCacheHeaderUtil

          public HttpCacheHeaderUtil()

  - ### Method Detail

    - #### sendNotModified

          public static void sendNotModified(javax.servlet.http.HttpServletResponse res)

    - #### sendPreconditionFailed

          public static void sendPreconditionFailed(javax.servlet.http.HttpServletResponse res)

    - #### calcEtag

          public static String calcEtag(SolrQueryRequest solrReq)

      Calculates a tag for the ETag header.
      Returns:
        a tag

    - #### isMatchingEtag

          public static boolean isMatchingEtag(List<String> headerList,
                                               String etag)

      Checks if one of the tags in the list equals the given etag.
      Parameters:
        `headerList` - the ETag header related header elements
        `etag` - the ETag to compare with
      Returns:
        true if the etag is found in one of the header elements - false otherwise

    - #### calcLastModified

          public static long calcLastModified(SolrQueryRequest solrReq)

      Calculate the appropriate last-modified time for Solr relative the current request.
      Returns:
        the timestamp to use as a last modified time.

    - #### setCacheControlHeader

          public static void setCacheControlHeader(SolrConfig conf,
                                                   javax.servlet.http.HttpServletResponse resp,
                                                   Method method)

      Set the Cache-Control HTTP header (and Expires if needed) based on the SolrConfig.
      Parameters:
        `conf` - The config of the SolrCore handling this request
        `resp` - The servlet response object to modify
        `method` - The request method (GET, POST, ...) used by this request

    - #### doCacheHeaderValidation

          public static boolean doCacheHeaderValidation(SolrQueryRequest solrReq,
                                                        javax.servlet.http.HttpServletRequest req,
                                                        Method reqMethod,
                                                        javax.servlet.http.HttpServletResponse resp)

      Sets HTTP Response cache validator headers appropriately and validates the HTTP Request against these using any conditional request headers. If the request contains conditional headers, and those headers indicate a match with the current known state of the system, this method will return "true" indicating that a 304 Status code can be returned, and no further processing is needed.
      Returns:
        true if the request contains conditional headers, and those headers indicate a match with the current known state of the system -- indicating that a 304 Status code can be returned to the client, and no further request processing is needed.

    - #### checkETagValidators

          public static boolean checkETagValidators(javax.servlet.http.HttpServletRequest req,
                                                    javax.servlet.http.HttpServletResponse resp,
                                                    Method reqMethod,
                                                    String etag)

      Check for etag related conditional headers and set status
      Returns:
        true if no request processing is necessary and HTTP response status has been set, false otherwise.

    - #### checkLastModValidators

          public static boolean checkLastModValidators(javax.servlet.http.HttpServletRequest req,
                                                       javax.servlet.http.HttpServletResponse resp,
                                                       long lastMod)

      Check for modify time related conditional headers and set status
      Returns:
        true if no request processing is necessary and HTTP response status has been set, false otherwise.

    - #### checkHttpCachingVeto

          public static void checkHttpCachingVeto(SolrQueryResponse solrRsp,
                                                  javax.servlet.http.HttpServletResponse resp,
                                                  Method reqMethod)

      Checks if the downstream request handler wants to avoid HTTP caching of the response.
      Parameters:
        `solrRsp` - The Solr response object
        `resp` - The HTTP servlet response object
        `reqMethod` - The HTTP request type

Copyright © 2000-2016 Apache Software Foundation. All Rights Reserved.