Class HttpClientContext
- All Implemented Interfaces:
org.apache.hc.core5.http.protocol.HttpContext
- Direct Known Subclasses:
HttpCacheContext, HttpClientContext.Delegate
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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static classInternal adaptor class that delegates all its method calls to a plainHttpContext. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringDeprecated.Use getter methodsstatic final StringDeprecated.Use getter methodsprivate AuthCacheprivate Map<org.apache.hc.core5.http.HttpHost, AuthExchange> static final StringDeprecated.Use getter methodsprivate org.apache.hc.core5.http.config.Lookup<AuthSchemeFactory> static final StringDeprecated.Use getter methodsstatic final StringDeprecated.Use getter methodsstatic final StringDeprecated.Use getter methodsprivate CookieOriginprivate CookieSpecstatic final StringDeprecated.Use getter methodsprivate org.apache.hc.core5.http.config.Lookup<CookieSpecFactory> private CookieStoreprivate CredentialsProviderstatic final StringDeprecated.Use getter methodsstatic final StringDeprecated.Use getter methodsprivate Stringstatic final StringDeprecated.Use getter methodsprivate StringStores thenextnoncevalue provided by the server in an HTTP response.static final StringDeprecated.Use getter methodsprivate RedirectLocationsstatic final StringDeprecated.Use getter methodsprivate RequestConfigprivate HttpRoutestatic final StringDeprecated.Use getter methodsprivate ObjectFields inherited from class org.apache.hc.core5.http.protocol.HttpCoreContext
CONNECTION_ENDPOINT, HTTP_REQUEST, HTTP_RESPONSE, SSL_SESSIONFields inherited from interface org.apache.hc.core5.http.protocol.HttpContext
RESERVED_PREFIX -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic HttpClientContextadapt(org.apache.hc.core5.http.protocol.HttpContext context) Deprecated.static HttpClientContextcast(org.apache.hc.core5.http.protocol.HttpContext context) Casts the given genericHttpContextasHttpClientContext.static HttpClientContextcastOrCreate(org.apache.hc.core5.http.protocol.HttpContext context) Casts the given genericHttpContextasHttpClientContextor creates newHttpClientContextif the given context is null.static HttpClientContextcreate()Represents aAuthCacheused in the context of the request execution.getAuthExchange(org.apache.hc.core5.http.HttpHost host) Map<org.apache.hc.core5.http.HttpHost, AuthExchange> Represents a map ofAuthExchanges performed in the context of the request execution.org.apache.hc.core5.http.config.Lookup<AuthSchemeFactory> Represents aAuthSchemeFactoryregistry used in the context of the request execution.Represents aCookieOriginproduced in the context of request execution.Represents aCookieSpecchosen in the context of request execution.org.apache.hc.core5.http.config.Lookup<CookieSpecFactory> Represents aCookieSpecFactoryregistry used in the context of the request execution.Represents aCookieStoreused in the context of the request execution.Represents aCredentialsProviderregistry used in the context of the request execution.Represents an identifier generated for the current message exchange executed in the given context.Represents current route used to execute message exchanges.Retrieves the storednextnoncevalue.Represents a collection of all redirects executed in the context of request execution.Represents anusedin the context of the request execution.final RequestConfigReturnsRequestConfigset in the context orRequestConfig.DEFAULTif not explicitly set in the context.Represents an arbitrary user token that identifies the user in the context of the request execution.<T> TgetUserToken(Class<T> clazz) Deprecated.UsegetUserToken()voidresetAuthExchange(org.apache.hc.core5.http.HttpHost host, AuthScheme authScheme) voidsetAuthCache(AuthCache authCache) voidsetAuthExchange(org.apache.hc.core5.http.HttpHost host, AuthExchange authExchange) voidsetAuthSchemeRegistry(org.apache.hc.core5.http.config.Lookup<AuthSchemeFactory> lookup) voidsetCookieOrigin(CookieOrigin cookieOrigin) voidsetCookieSpec(CookieSpec cookieSpec) voidsetCookieSpecRegistry(org.apache.hc.core5.http.config.Lookup<CookieSpecFactory> lookup) voidsetCookieStore(CookieStore cookieStore) voidsetCredentialsProvider(CredentialsProvider credentialsProvider) voidsetExchangeId(String exchangeId) voidsetNextNonce(String nextNonce) Sets thenextnoncevalue directly as an instance attribute.voidsetRedirectLocations(RedirectLocations redirectLocations) voidsetRequestConfig(RequestConfig requestConfig) voidvoidsetUserToken(Object userToken) 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
-
Field Details
-
HTTP_ROUTE
-
REDIRECT_LOCATIONS
-
COOKIESPEC_REGISTRY
-
COOKIE_SPEC
-
COOKIE_ORIGIN
-
COOKIE_STORE
-
CREDS_PROVIDER
-
AUTH_CACHE
-
AUTH_EXCHANGE_MAP
-
USER_TOKEN
-
AUTHSCHEME_REGISTRY
-
REQUEST_CONFIG
-
EXCHANGE_ID
-
route
-
redirectLocations
-
cookieSpec
-
cookieOrigin
-
authExchangeMap
-
exchangeId
-
cookieSpecFactoryLookup
-
authSchemeFactoryLookup
-
cookieStore
-
credentialsProvider
-
authCache
-
userToken
-
requestConfig
-
nextNonce
Stores thenextnoncevalue provided by the server in an HTTP response.In the context of HTTP Digest Access Authentication, the
nextnonceparameter 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-Infoheader. Once used, this value may be cleared from the context to avoid reuse.- Since:
- 5.5
-
-
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
Casts the given genericHttpContextasHttpClientContext.- Since:
- 5.4
-
castOrCreate
Casts the given genericHttpContextasHttpClientContextor creates newHttpClientContextif the given context is null.- Since:
- 5.4
-
create
-
getHttpRoute
Represents current route used to execute message exchanges.This context attribute is expected to be populated by the protocol handler.
-
setRoute
- Since:
- 5.4
-
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
- Since:
- 5.4
-
getCookieStore
Represents aCookieStoreused in the context of the request execution.This context attribute can be set by the caller.
-
setCookieStore
-
getCookieSpec
Represents aCookieSpecchosen in the context of request execution.This context attribute is expected to be populated by the protocol handler.
-
setCookieSpec
- Since:
- 5.4
-
getCookieOrigin
Represents aCookieOriginproduced in the context of request execution.This context attribute is expected to be populated by the protocol handler.
-
setCookieOrigin
- Since:
- 5.4
-
getCookieSpecRegistry
Represents aCookieSpecFactoryregistry used in the context of the request execution.This context attribute can be set by the caller.
-
setCookieSpecRegistry
-
getAuthSchemeRegistry
Represents aAuthSchemeFactoryregistry used in the context of the request execution.This context attribute can be set by the caller.
-
setAuthSchemeRegistry
-
getCredentialsProvider
Represents aCredentialsProviderregistry used in the context of the request execution.This context attribute can be set by the caller.
-
setCredentialsProvider
-
getAuthCache
-
setAuthCache
-
getAuthExchanges
Represents a map ofAuthExchanges performed in the context of the request execution.This context attribute is expected to be populated by the protocol handler.
- Since:
- 5.0
-
getAuthExchange
- Since:
- 5.0
-
setAuthExchange
- Since:
- 5.0
-
resetAuthExchange
- Since:
- 5.0
-
getUserToken
Deprecated.UsegetUserToken() -
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
-
getRequestConfig
Represents anusedin the context of the request execution.This context attribute can be set by the caller.
-
getRequestConfigOrDefault
ReturnsRequestConfigset in the context orRequestConfig.DEFAULTif not explicitly set in the context.- Since:
- 5.4
-
setRequestConfig
-
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
- Since:
- 5.1
-
getNextNonce
Retrieves the storednextnoncevalue.- Returns:
- the
nextnonceparameter value, ornullif not set - Since:
- 5.5
-
setNextNonce
Sets thenextnoncevalue directly as an instance attribute.- Parameters:
nextNonce- the nonce value to set- Since:
- 5.5
-