Class HttpClientContext

java.lang.Object
org.apache.hc.core5.http.protocol.HttpCoreContext
org.apache.hc.client5.http.protocol.HttpClientContext
All Implemented Interfaces:
org.apache.hc.core5.http.protocol.HttpContext
Direct Known Subclasses:
HttpCacheContext, HttpClientContext.Delegate

public class HttpClientContext extends org.apache.hc.core5.http.protocol.HttpCoreContext
Client 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 Details

  • Constructor Details

    • HttpClientContext

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

      public HttpClientContext()
  • Method Details

    • adapt

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

      public static HttpClientContext cast(org.apache.hc.core5.http.protocol.HttpContext context)
      Casts the given generic HttpContext as HttpClientContext.
      Since:
      5.4
    • castOrCreate

      public static HttpClientContext castOrCreate(org.apache.hc.core5.http.protocol.HttpContext context)
      Casts the given generic HttpContext as HttpClientContext or creates new HttpClientContext if the given context is null.
      Since:
      5.4
    • create

      public static HttpClientContext create()
    • getHttpRoute

      public RouteInfo getHttpRoute()
      Represents current route used to execute message exchanges.

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

    • setRoute

      @Internal public void setRoute(HttpRoute route)
      Since:
      5.4
    • getRedirectLocations

      public RedirectLocations getRedirectLocations()
      Represents a collection of all redirects executed in the context of request execution.

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

    • setRedirectLocations

      @Internal public void setRedirectLocations(RedirectLocations redirectLocations)
      Since:
      5.4
    • getCookieStore

      public CookieStore getCookieStore()
      Represents a CookieStore used in the context of the request execution.

      This context attribute can be set by the caller.

    • setCookieStore

      public void setCookieStore(CookieStore cookieStore)
    • getCookieSpec

      public CookieSpec getCookieSpec()
      Represents a CookieSpec chosen in the context of request execution.

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

    • setCookieSpec

      @Internal public void setCookieSpec(CookieSpec cookieSpec)
      Since:
      5.4
    • getCookieOrigin

      public CookieOrigin getCookieOrigin()
      Represents a CookieOrigin produced in the context of request execution.

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

    • setCookieOrigin

      @Internal public void setCookieOrigin(CookieOrigin cookieOrigin)
      Since:
      5.4
    • getCookieSpecRegistry

      public org.apache.hc.core5.http.config.Lookup<CookieSpecFactory> getCookieSpecRegistry()
      Represents a CookieSpecFactory registry used in the context of the request execution.

      This context attribute can be set by the caller.

    • setCookieSpecRegistry

      public void setCookieSpecRegistry(org.apache.hc.core5.http.config.Lookup<CookieSpecFactory> lookup)
    • getAuthSchemeRegistry

      public org.apache.hc.core5.http.config.Lookup<AuthSchemeFactory> getAuthSchemeRegistry()
      Represents a AuthSchemeFactory registry used in the context of the request execution.

      This context attribute can be set by the caller.

    • setAuthSchemeRegistry

      public void setAuthSchemeRegistry(org.apache.hc.core5.http.config.Lookup<AuthSchemeFactory> lookup)
    • getCredentialsProvider

      public CredentialsProvider getCredentialsProvider()
      Represents a CredentialsProvider registry used in the context of the request execution.

      This context attribute can be set by the caller.

    • setCredentialsProvider

      public void setCredentialsProvider(CredentialsProvider credentialsProvider)
    • getAuthCache

      public AuthCache getAuthCache()
      Represents a AuthCache used in the context of the request execution.

      This context attribute can be set by the caller.

    • setAuthCache

      public void setAuthCache(AuthCache authCache)
    • getAuthExchanges

      public Map<org.apache.hc.core5.http.HttpHost, AuthExchange> getAuthExchanges()
      Represents a map of AuthExchanges performed in the context of the request execution.

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

      Since:
      5.0
    • getAuthExchange

      public AuthExchange getAuthExchange(org.apache.hc.core5.http.HttpHost host)
      Since:
      5.0
    • setAuthExchange

      public void setAuthExchange(org.apache.hc.core5.http.HttpHost host, AuthExchange authExchange)
      Since:
      5.0
    • resetAuthExchange

      public void resetAuthExchange(org.apache.hc.core5.http.HttpHost host, AuthScheme authScheme)
      Since:
      5.0
    • getUserToken

      @Deprecated public <T> T getUserToken(Class<T> clazz)
      Deprecated.
    • getUserToken

      public Object getUserToken()
      Represents an arbitrary user token that identifies the user in the context of the request execution.

      This context attribute can be set by the caller.

    • setUserToken

      public void setUserToken(Object userToken)
    • getRequestConfig

      public RequestConfig getRequestConfig()
      Represents an used in the context of the request execution.

      This context attribute can be set by the caller.

    • getRequestConfigOrDefault

      public final RequestConfig getRequestConfigOrDefault()
      Returns RequestConfig set in the context or RequestConfig.DEFAULT if not explicitly set in the context.
      Since:
      5.4
    • setRequestConfig

      public void setRequestConfig(RequestConfig requestConfig)
    • getExchangeId

      public String getExchangeId()
      Represents an identifier generated for the current message exchange executed in the given context.

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

      Since:
      5.1
    • setExchangeId

      public void setExchangeId(String exchangeId)
      Since:
      5.1
    • getNextNonce

      @Internal public String getNextNonce()
      Retrieves the stored nextnonce value.
      Returns:
      the nextnonce parameter value, or null if not set
      Since:
      5.5
    • setNextNonce

      @Internal public void setNextNonce(String nextNonce)
      Sets the nextnonce value directly as an instance attribute.
      Parameters:
      nextNonce - the nonce value to set
      Since:
      5.5