Class 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 Detail

      • HTTP_ROUTE

        @Deprecated
        public static final java.lang.String HTTP_ROUTE
        Deprecated.
        Use getter methods
        See Also:
        Constant Field Values
      • REDIRECT_LOCATIONS

        @Deprecated
        public static final java.lang.String REDIRECT_LOCATIONS
        Deprecated.
        Use getter methods
        See Also:
        Constant Field Values
      • COOKIESPEC_REGISTRY

        @Deprecated
        public static final java.lang.String COOKIESPEC_REGISTRY
        Deprecated.
        Use getter methods
        See Also:
        Constant Field Values
      • COOKIE_SPEC

        @Deprecated
        public static final java.lang.String COOKIE_SPEC
        Deprecated.
        Use getter methods
        See Also:
        Constant Field Values
      • COOKIE_ORIGIN

        @Deprecated
        public static final java.lang.String COOKIE_ORIGIN
        Deprecated.
        Use getter methods
        See Also:
        Constant Field Values
      • COOKIE_STORE

        @Deprecated
        public static final java.lang.String COOKIE_STORE
        Deprecated.
        Use getter methods
        See Also:
        Constant Field Values
      • CREDS_PROVIDER

        @Deprecated
        public static final java.lang.String CREDS_PROVIDER
        Deprecated.
        Use getter methods
        See Also:
        Constant Field Values
      • AUTH_CACHE

        @Deprecated
        public static final java.lang.String AUTH_CACHE
        Deprecated.
        Use getter methods
        See Also:
        Constant Field Values
      • AUTH_EXCHANGE_MAP

        @Deprecated
        public static final java.lang.String AUTH_EXCHANGE_MAP
        Deprecated.
        Use getter methods
        See Also:
        Constant Field Values
      • USER_TOKEN

        @Deprecated
        public static final java.lang.String USER_TOKEN
        Deprecated.
        Use getter methods
        See Also:
        Constant Field Values
      • AUTHSCHEME_REGISTRY

        @Deprecated
        public static final java.lang.String AUTHSCHEME_REGISTRY
        Deprecated.
        Use getter methods
        See Also:
        Constant Field Values
      • REQUEST_CONFIG

        @Deprecated
        public static final java.lang.String REQUEST_CONFIG
        Deprecated.
        Use getter methods
        See Also:
        Constant Field Values
      • EXCHANGE_ID

        @Deprecated
        public static final java.lang.String EXCHANGE_ID
        Deprecated.
        Use getter methods
        See Also:
        Constant Field Values
      • authExchangeMap

        private java.util.Map<org.apache.hc.core5.http.HttpHost,​AuthExchange> authExchangeMap
      • exchangeId

        private java.lang.String exchangeId
      • cookieSpecFactoryLookup

        private org.apache.hc.core5.http.config.Lookup<CookieSpecFactory> cookieSpecFactoryLookup
      • authSchemeFactoryLookup

        private org.apache.hc.core5.http.config.Lookup<AuthSchemeFactory> authSchemeFactoryLookup
      • userToken

        private java.lang.Object userToken
      • nextNonce

        private java.lang.String nextNonce
        Stores the nextnonce value provided by the server in an HTTP response.

        In the context of HTTP Digest Access Authentication, the nextnonce parameter is used by the client in subsequent requests to ensure one-time or session-bound usage of nonce values, enhancing security by preventing replay attacks.

        This field is set by an interceptor or other component that processes the server's response containing the Authentication-Info header. Once used, this value may be cleared from the context to avoid reuse.

        Since:
        5.5
    • Constructor Detail

      • HttpClientContext

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

        public HttpClientContext()
    • Method Detail

      • cast

        public static HttpClientContext cast​(org.apache.hc.core5.http.protocol.HttpContext context)
        Casts the given generic HttpContext as HttpClientContext.
        Since:
        5.4
      • 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 java.util.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​(java.lang.Class<T> clazz)
        Deprecated.
      • getUserToken

        public java.lang.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​(java.lang.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.

      • setRequestConfig

        public void setRequestConfig​(RequestConfig requestConfig)
      • getExchangeId

        public java.lang.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​(java.lang.String exchangeId)
        Since:
        5.1
      • getNextNonce

        @Internal
        public java.lang.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​(java.lang.String nextNonce)
        Sets the nextnonce value directly as an instance attribute.
        Parameters:
        nextNonce - the nonce value to set
        Since:
        5.5