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 Object implements HttpContext
Core execution HttpContext.

IMPORTANT: This class is NOT thread-safe and MUST NOT be used concurrently by multiple message exchanges.

Since:
4.3
  • Field Details

  • Constructor Details

    • HttpCoreContext

      public HttpCoreContext(HttpContext parentContext)
    • HttpCoreContext

      public HttpCoreContext()
  • Method Details

    • create

      public static HttpCoreContext create()
    • adapt

      @Deprecated public static HttpCoreContext adapt(HttpContext context)
      Deprecated.
    • cast

      public static HttpCoreContext cast(HttpContext context)
      Casts the given generic HttpContext as HttpCoreContext.
      Since:
      5.3
    • castOrCreate

      public static HttpCoreContext castOrCreate(HttpContext context)
      Casts the given generic HttpContext as HttpCoreContext or creates new HttpCoreContext if 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:
      getProtocolVersion in interface HttpContext
      Since:
      5.0
    • setProtocolVersion

      public void setProtocolVersion(ProtocolVersion version)
      Description copied from interface: HttpContext
      Sets protocol version used in this context.
      Specified by:
      setProtocolVersion in interface HttpContext
      Since:
      5.0
    • getAttribute

      public Object getAttribute(String id)
      Description copied from interface: HttpContext
      Obtains attribute with the given name.
      Specified by:
      getAttribute in interface HttpContext
      Parameters:
      id - the attribute name.
      Returns:
      attribute value, or null if not set.
    • setAttribute

      public Object setAttribute(String id, Object obj)
      Description copied from interface: HttpContext
      Sets value of the attribute with the given name.
      Specified by:
      setAttribute in interface HttpContext
      Parameters:
      id - the attribute name.
      obj - the attribute value.
      Returns:
      the previous value associated with id, or null if there was no mapping for id.
    • removeAttribute

      public Object removeAttribute(String id)
      Description copied from interface: HttpContext
      Removes attribute with the given name from the context.
      Specified by:
      removeAttribute in interface HttpContext
      Parameters:
      id - the attribute name.
      Returns:
      attribute value, or null if not set.
    • getAttribute

      public <T> T getAttribute(String id, 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 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(SSLSession sslSession)
      Since:
      5.3
    • toString

      public String toString()
      Overrides:
      toString in class Object