org.apache.hc.client5.http.cache

## Class HttpCacheContext

- java.lang.Object
- - org.apache.hc.core5.http.protocol.HttpCoreContext
  - - org.apache.hc.client5.http.protocol.HttpClientContext
    - - org.apache.hc.client5.http.cache.HttpCacheContext

- All Implemented Interfaces:
    org.apache.hc.core5.http.protocol.HttpContext

      public class HttpCacheContext
      extends HttpClientContext

  Cache execution `HttpContext`. This class can be re-used for multiple consecutive logically related request executions that represent a single communication session. This context may not be used concurrently.

  IMPORTANT: This class is NOT thread-safe and MUST NOT be used concurrently by multiple message exchanges.

  Since:
    4.3

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `CACHE_RESPONSE_STATUS` Deprecated. Use getter methods

    - ### Fields inherited from class org.apache.hc.client5.http.protocol.HttpClientContext

      `AUTH_CACHE, AUTH_EXCHANGE_MAP, AUTHSCHEME_REGISTRY, COOKIE_ORIGIN, COOKIE_SPEC, COOKIE_STORE, COOKIESPEC_REGISTRY, CREDS_PROVIDER, EXCHANGE_ID, HTTP_ROUTE, REDIRECT_LOCATIONS, REQUEST_CONFIG, USER_TOKEN`

    - ### Fields inherited from class org.apache.hc.core5.http.protocol.HttpCoreContext

      `CONNECTION_ENDPOINT, HTTP_REQUEST, HTTP_RESPONSE, SSL_SESSION`

    - ### Fields inherited from interface org.apache.hc.core5.http.protocol.HttpContext

      `RESERVED_PREFIX`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `HttpCacheContext()`
    `HttpCacheContext(org.apache.hc.core5.http.protocol.HttpContext context)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `static HttpCacheContext` | `adapt(org.apache.hc.core5.http.protocol.HttpContext context)` Deprecated. Use `castOrCreate(HttpContext)`.
    `static HttpCacheContext` | `cast(org.apache.hc.core5.http.protocol.HttpContext context)` Casts the given generic `HttpContext` as `HttpCacheContext` or throws an `IllegalStateException` if the given context is not suitable.
    `static HttpCacheContext` | `castOrCreate(org.apache.hc.core5.http.protocol.HttpContext context)` Casts the given generic `HttpContext` as `HttpCacheContext` or creates new `HttpCacheContext` if the given context is null..
    `static HttpCacheContext` | `create()`
    `HttpCacheEntry` | `getCacheEntry()` Represents the cache entry the resource of which has been used to generate the response.
    `CacheResponseStatus` | `getCacheResponseStatus()` Represents an outcome of the cache operation and the way the response has been generated.
    `RequestCacheControl` | `getRequestCacheControl()` Represents cache control requested by the client.
    `RequestCacheControl` | `getRequestCacheControlOrDefault()` Returns cache control requested by the client or `RequestCacheControl.DEFAULT` if not explicitly set in the context.
    `ResponseCacheControl` | `getResponseCacheControl()` Represents cache control enforced by the server.
    `ResponseCacheControl` | `getResponseCacheControlOrDefault()` Represents cache control enforced by the server or `ResponseCacheControl.DEFAULT` if not explicitly set in the context.
    `void` | `setCacheEntry(HttpCacheEntry cacheEntry)`
    `void` | `setCacheResponseStatus(CacheResponseStatus responseStatus)`
    `void` | `setRequestCacheControl(RequestCacheControl requestCacheControl)`
    `void` | `setResponseCacheControl(ResponseCacheControl responseCacheControl)`

    - ### Methods inherited from class org.apache.hc.client5.http.protocol.HttpClientContext

      `getAuthCache, getAuthExchange, getAuthExchanges, getAuthSchemeRegistry, getCookieOrigin, getCookieSpec, getCookieSpecRegistry, getCookieStore, getCredentialsProvider, getExchangeId, getHttpRoute, getRedirectLocations, getRequestConfig, getRequestConfigOrDefault, getUserToken, getUserToken, resetAuthExchange, setAuthCache, setAuthExchange, setAuthSchemeRegistry, setCookieOrigin, setCookieSpec, setCookieSpecRegistry, setCookieStore, setCredentialsProvider, setExchangeId, setRedirectLocations, setRequestConfig, setRoute, setUserToken`

    - ### Methods inherited from class org.apache.hc.core5.http.protocol.HttpCoreContext

      `getAttribute, getAttribute, getEndpointDetails, getProtocolVersion, getRequest, getResponse, getSSLSession, removeAttribute, setAttribute, setEndpointDetails, setProtocolVersion, setRequest, setResponse, setSSLSession, toString`

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

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

- - ### Field Detail

    - #### CACHE_RESPONSE_STATUS

          @Deprecated
          public static final String CACHE_RESPONSE_STATUS

      Deprecated. Use getter methods
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### HttpCacheContext

          public HttpCacheContext(org.apache.hc.core5.http.protocol.HttpContext context)

    - #### HttpCacheContext

          public HttpCacheContext()

  - ### Method Detail

    - #### adapt

          @Deprecated
          public static HttpCacheContext adapt(org.apache.hc.core5.http.protocol.HttpContext context)

      Deprecated. Use `castOrCreate(HttpContext)`.

    - #### cast

          public static HttpCacheContext cast(org.apache.hc.core5.http.protocol.HttpContext context)

      Casts the given generic `HttpContext` as `HttpCacheContext` or throws an `IllegalStateException` if the given context is not suitable.
      Since:
        5.4

    - #### castOrCreate

          public static HttpCacheContext castOrCreate(org.apache.hc.core5.http.protocol.HttpContext context)

      Casts the given generic `HttpContext` as `HttpCacheContext` or creates new `HttpCacheContext` if the given context is null..
      Since:
        5.4

    - #### create

          public static HttpCacheContext create()

    - #### getCacheResponseStatus

          public CacheResponseStatus getCacheResponseStatus()

      Represents an outcome of the cache operation and the way the response has been generated.

      This context attribute is expected to be populated by the protocol handler.

    - #### setCacheResponseStatus

          @Internal
          public void setCacheResponseStatus(CacheResponseStatus responseStatus)

      Since:
        5.4

    - #### getRequestCacheControl

          public RequestCacheControl getRequestCacheControl()

      Represents cache control requested by the client.

      This context attribute is expected to be set by the caller.

      Since:
        5.4

    - #### getRequestCacheControlOrDefault

          public final RequestCacheControl getRequestCacheControlOrDefault()

      Returns cache control requested by the client or `RequestCacheControl.DEFAULT` if not explicitly set in the context.
      Since:
        5.4

    - #### setRequestCacheControl

          @Internal
          public void setRequestCacheControl(RequestCacheControl requestCacheControl)

      Since:
        5.4

    - #### getResponseCacheControl

          public ResponseCacheControl getResponseCacheControl()

      Represents cache control enforced by the server.

      This context attribute is expected to be populated by the protocol handler.

      Since:
        5.4

    - #### getResponseCacheControlOrDefault

          public final ResponseCacheControl getResponseCacheControlOrDefault()

      Represents cache control enforced by the server or `ResponseCacheControl.DEFAULT` if not explicitly set in the context.
      Since:
        5.4

    - #### setResponseCacheControl

          @Internal
          public void setResponseCacheControl(ResponseCacheControl responseCacheControl)

      Since:
        5.4

    - #### getCacheEntry

          public HttpCacheEntry getCacheEntry()

      Represents the cache entry the resource of which has been used to generate the response.

      This context attribute is expected to be populated by the protocol handler.

      Since:
        5.4

    - #### setCacheEntry

          @Internal
          public void setCacheEntry(HttpCacheEntry cacheEntry)

      Since:
        5.4

Copyright © 1999–2021 The Apache Software Foundation. All rights reserved.