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
public class HttpClientContext extends org.apache.hc.core5.http.protocol.HttpCoreContextClient executionHttpContext. 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 Description static java.lang.StringAUTH_CACHEDeprecated.Use getter methodsstatic java.lang.StringAUTH_EXCHANGE_MAPDeprecated.Use getter methodsstatic java.lang.StringAUTHSCHEME_REGISTRYDeprecated.Use getter methodsstatic java.lang.StringCOOKIE_ORIGINDeprecated.Use getter methodsstatic java.lang.StringCOOKIE_SPECDeprecated.Use getter methodsstatic java.lang.StringCOOKIE_STOREDeprecated.Use getter methodsstatic java.lang.StringCOOKIESPEC_REGISTRYDeprecated.Use getter methodsstatic java.lang.StringCREDS_PROVIDERDeprecated.Use getter methodsstatic java.lang.StringEXCHANGE_IDDeprecated.Use getter methodsstatic java.lang.StringHTTP_ROUTEDeprecated.Use getter methodsstatic java.lang.StringREDIRECT_LOCATIONSDeprecated.Use getter methodsstatic java.lang.StringREQUEST_CONFIGDeprecated.Use getter methodsstatic java.lang.StringUSER_TOKENDeprecated.Use getter methods
-
Constructor Summary
Constructors Constructor Description HttpClientContext()HttpClientContext(org.apache.hc.core5.http.protocol.HttpContext context)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static 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()AuthCachegetAuthCache()Represents aAuthCacheused in the context of the request execution.AuthExchangegetAuthExchange(org.apache.hc.core5.http.HttpHost host)java.util.Map<org.apache.hc.core5.http.HttpHost,AuthExchange>getAuthExchanges()Represents a map ofAuthExchanges performed in the context of the request execution.org.apache.hc.core5.http.config.Lookup<AuthSchemeFactory>getAuthSchemeRegistry()Represents aAuthSchemeFactoryregistry used in the context of the request execution.CookieOrigingetCookieOrigin()Represents aCookieOriginproduced in the context of request execution.CookieSpecgetCookieSpec()Represents aCookieSpecchosen in the context of request execution.org.apache.hc.core5.http.config.Lookup<CookieSpecFactory>getCookieSpecRegistry()Represents aCookieSpecFactoryregistry used in the context of the request execution.CookieStoregetCookieStore()Represents aCookieStoreused in the context of the request execution.CredentialsProvidergetCredentialsProvider()Represents aCredentialsProviderregistry used in the context of the request execution.java.lang.StringgetExchangeId()Represents an identifier generated for the current message exchange executed in the given context.RouteInfogetHttpRoute()Represents current route used to execute message exchanges.java.lang.StringgetNextNonce()Retrieves the storednextnoncevalue.RedirectLocationsgetRedirectLocations()Represents a collection of all redirects executed in the context of request execution.RequestConfiggetRequestConfig()Represents anusedin the context of the request execution.RequestConfiggetRequestConfigOrDefault()ReturnsRequestConfigset in the context orRequestConfig.DEFAULTif not explicitly set in the context.java.lang.ObjectgetUserToken()Represents an arbitrary user token that identifies the user in the context of the request execution.<T> TgetUserToken(java.lang.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(java.lang.String exchangeId)voidsetNextNonce(java.lang.String nextNonce)Sets thenextnoncevalue directly as an instance attribute.voidsetRedirectLocations(RedirectLocations redirectLocations)voidsetRequestConfig(RequestConfig requestConfig)voidsetRoute(HttpRoute route)voidsetUserToken(java.lang.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 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
-
-
Method Detail
-
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 genericHttpContextasHttpClientContext.- Since:
- 5.4
-
castOrCreate
public static HttpClientContext castOrCreate(org.apache.hc.core5.http.protocol.HttpContext context)
Casts the given genericHttpContextasHttpClientContextor creates newHttpClientContextif 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 aCookieStoreused 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 aCookieSpecchosen 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 aCookieOriginproduced 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 aCookieSpecFactoryregistry 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 aAuthSchemeFactoryregistry 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 aCredentialsProviderregistry 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 aAuthCacheused 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 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
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.UsegetUserToken()
-
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 anusedin the context of the request execution.This context attribute can be set by the caller.
-
getRequestConfigOrDefault
public final RequestConfig getRequestConfigOrDefault()
ReturnsRequestConfigset in the context orRequestConfig.DEFAULTif not explicitly set in the context.- Since:
- 5.4
-
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 storednextnoncevalue.- Returns:
- the
nextnonceparameter value, ornullif not set - Since:
- 5.5
-
setNextNonce
@Internal public void setNextNonce(java.lang.String nextNonce)
Sets thenextnoncevalue directly as an instance attribute.- Parameters:
nextNonce- the nonce value to set- Since:
- 5.5
-
-