Class HttpCoreContext
- java.lang.Object
-
- org.apache.hc.core5.http.protocol.HttpCoreContext
-
- All Implemented Interfaces:
HttpContext
- Direct Known Subclasses:
HttpCoreContext.Delegate
public class HttpCoreContext extends java.lang.Object implements HttpContext
Core executionHttpContext.IMPORTANT: This class is NOT thread-safe and MUST NOT be used concurrently by multiple message exchanges.
- Since:
- 4.3
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classHttpCoreContext.DelegateInternal adaptor class that delegates all its method calls to a plainHttpContext.
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringCONNECTION_ENDPOINTDeprecated.Use getter methodsprivate EndpointDetailsendpointDetailsstatic java.lang.StringHTTP_REQUESTDeprecated.Use getter methodsstatic java.lang.StringHTTP_RESPONSEDeprecated.Use getter methodsprivate java.util.Map<java.lang.String,java.lang.Object>mapprivate HttpContextparentContextprivate HttpRequestrequestprivate HttpResponseresponsestatic java.lang.StringSSL_SESSIONDeprecated.Use getter methodsprivate javax.net.ssl.SSLSessionsslSessionprivate ProtocolVersionversion-
Fields inherited from interface org.apache.hc.core5.http.protocol.HttpContext
RESERVED_PREFIX
-
-
Constructor Summary
Constructors Constructor Description HttpCoreContext()HttpCoreContext(HttpContext parentContext)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static HttpCoreContextadapt(HttpContext context)Deprecated.Usecast(HttpContext).static HttpCoreContextcast(HttpContext context)Casts the given genericHttpContextasHttpCoreContext.static HttpCoreContextcastOrCreate(HttpContext context)Casts the given genericHttpContextasHttpCoreContextor creates newHttpCoreContextif the given context is null.static HttpCoreContextcreate()java.lang.ObjectgetAttribute(java.lang.String id)Obtains attribute with the given name.<T> TgetAttribute(java.lang.String id, java.lang.Class<T> clazz)EndpointDetailsgetEndpointDetails()Represents current connection endpoint details.ProtocolVersiongetProtocolVersion()Represents the protocol version used by the message exchange.HttpRequestgetRequest()Represents current request message head.HttpResponsegetResponse()Represents current response message head.javax.net.ssl.SSLSessiongetSSLSession()Represents current TLS session details.java.lang.ObjectremoveAttribute(java.lang.String id)Removes attribute with the given name from the context.java.lang.ObjectsetAttribute(java.lang.String id, java.lang.Object obj)Sets value of the attribute with the given name.voidsetEndpointDetails(EndpointDetails endpointDetails)voidsetProtocolVersion(ProtocolVersion version)Sets protocol version used in this context.voidsetRequest(HttpRequest request)voidsetResponse(HttpResponse response)voidsetSSLSession(javax.net.ssl.SSLSession sslSession)java.lang.StringtoString()
-
-
-
Field Detail
-
CONNECTION_ENDPOINT
@Deprecated public static final java.lang.String CONNECTION_ENDPOINT
Deprecated.Use getter methods- See Also:
- Constant Field Values
-
SSL_SESSION
@Deprecated public static final java.lang.String SSL_SESSION
Deprecated.Use getter methods- See Also:
- Constant Field Values
-
HTTP_REQUEST
@Deprecated public static final java.lang.String HTTP_REQUEST
Deprecated.Use getter methods- See Also:
- Constant Field Values
-
HTTP_RESPONSE
@Deprecated public static final java.lang.String HTTP_RESPONSE
Deprecated.Use getter methods- See Also:
- Constant Field Values
-
parentContext
private final HttpContext parentContext
-
map
private java.util.Map<java.lang.String,java.lang.Object> map
-
version
private ProtocolVersion version
-
request
private HttpRequest request
-
response
private HttpResponse response
-
endpointDetails
private EndpointDetails endpointDetails
-
sslSession
private javax.net.ssl.SSLSession sslSession
-
-
Constructor Detail
-
HttpCoreContext
public HttpCoreContext(HttpContext parentContext)
-
HttpCoreContext
public HttpCoreContext()
-
-
Method Detail
-
create
public static HttpCoreContext create()
-
adapt
@Deprecated public static HttpCoreContext adapt(HttpContext context)
Deprecated.Usecast(HttpContext).
-
cast
public static HttpCoreContext cast(HttpContext context)
Casts the given genericHttpContextasHttpCoreContext.- Since:
- 5.3
-
castOrCreate
public static HttpCoreContext castOrCreate(HttpContext context)
Casts the given genericHttpContextasHttpCoreContextor creates newHttpCoreContextif the given context is null.- Since:
- 5.4
-
getProtocolVersion
public ProtocolVersion getProtocolVersion()
Represents the protocol version used by the message exchange.This context attribute is expected to be populated by the protocol handler in the course of request execution.
- Specified by:
getProtocolVersionin interfaceHttpContext- Since:
- 5.0
-
setProtocolVersion
public void setProtocolVersion(ProtocolVersion version)
Description copied from interface:HttpContextSets protocol version used in this context.- Specified by:
setProtocolVersionin interfaceHttpContext- Since:
- 5.0
-
getAttribute
public java.lang.Object getAttribute(java.lang.String id)
Description copied from interface:HttpContextObtains attribute with the given name.- Specified by:
getAttributein interfaceHttpContext- Parameters:
id- the attribute name.- Returns:
- attribute value, or
nullif not set.
-
setAttribute
public java.lang.Object setAttribute(java.lang.String id, java.lang.Object obj)Description copied from interface:HttpContextSets value of the attribute with the given name.- Specified by:
setAttributein interfaceHttpContext- Parameters:
id- the attribute name.obj- the attribute value.- Returns:
- the previous value associated with
id, ornullif there was no mapping forid.
-
removeAttribute
public java.lang.Object removeAttribute(java.lang.String id)
Description copied from interface:HttpContextRemoves attribute with the given name from the context.- Specified by:
removeAttributein interfaceHttpContext- Parameters:
id- the attribute name.- Returns:
- attribute value, or
nullif not set.
-
getAttribute
public <T> T getAttribute(java.lang.String id, java.lang.Class<T> clazz)
-
getRequest
public HttpRequest getRequest()
Represents current request message head.This context attribute is expected to be populated by the protocol handler in the course of request execution.
-
setRequest
@Internal public void setRequest(HttpRequest request)
- Since:
- 5.3
-
getResponse
public HttpResponse getResponse()
Represents current response message head.This context attribute is expected to be populated by the protocol handler in the course of request execution.
-
setResponse
@Internal public void setResponse(HttpResponse response)
- Since:
- 5.3
-
getEndpointDetails
public EndpointDetails getEndpointDetails()
Represents current connection endpoint details.This context attribute is expected to be populated by the protocol handler in the course of request execution.
- Since:
- 5.0
-
setEndpointDetails
@Internal public void setEndpointDetails(EndpointDetails endpointDetails)
- Since:
- 5.3
-
getSSLSession
public javax.net.ssl.SSLSession getSSLSession()
Represents current TLS session details.This context attribute is expected to be populated by the protocol handler in the course of request execution.
- Since:
- 5.0
-
setSSLSession
@Internal public void setSSLSession(javax.net.ssl.SSLSession sslSession)
- Since:
- 5.3
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-