org.apache.hc.core5.http.protocol

## Class HttpCoreContext

- java.lang.Object
- - org.apache.hc.core5.http.protocol.HttpCoreContext

- All Implemented Interfaces:
    HttpContext

      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 Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `CONNECTION_ENDPOINT` Deprecated. Use getter methods
    `static String` | `HTTP_REQUEST` Deprecated. Use getter methods
    `static String` | `HTTP_RESPONSE` Deprecated. Use getter methods
    `static String` | `SSL_SESSION` Deprecated. Use getter methods

    - ### Fields inherited from interface org.apache.hc.core5.http.protocol.HttpContext

      `RESERVED_PREFIX`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `HttpCoreContext()`
    `HttpCoreContext(HttpContext parentContext)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `static HttpCoreContext` | `adapt(HttpContext context)` Deprecated. Use `cast(HttpContext)`.
    `static HttpCoreContext` | `cast(HttpContext context)` Casts the given generic `HttpContext` as `HttpCoreContext`.
    `static HttpCoreContext` | `castOrCreate(HttpContext context)` Casts the given generic `HttpContext` as `HttpCoreContext` or creates new `HttpCoreContext` if the given context is null.
    `static HttpCoreContext` | `create()`
    `Object` | `getAttribute(String id)` Obtains attribute with the given name.
    `<T> T` | `getAttribute(String id, Class<T> clazz)`
    `EndpointDetails` | `getEndpointDetails()` Represents current connection endpoint details.
    `ProtocolVersion` | `getProtocolVersion()` Represents the protocol version used by the message exchange.
    `HttpRequest` | `getRequest()` Represents current request message head.
    `HttpResponse` | `getResponse()` Represents current response message head.
    `SSLSession` | `getSSLSession()` Represents current TLS session details.
    `Object` | `removeAttribute(String id)` Removes attribute with the given name from the context.
    `Object` | `setAttribute(String id, Object obj)` Sets value of the attribute with the given name.
    `void` | `setEndpointDetails(EndpointDetails endpointDetails)`
    `void` | `setProtocolVersion(ProtocolVersion version)` Sets protocol version used in this context.
    `void` | `setRequest(HttpRequest request)`
    `void` | `setResponse(HttpResponse response)`
    `void` | `setSSLSession(SSLSession sslSession)`
    `String` | `toString()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### CONNECTION_ENDPOINT

          @Deprecated
          public static final String CONNECTION_ENDPOINT

      Deprecated. Use getter methods
      See Also:
        Constant Field Values

    - #### SSL_SESSION

          @Deprecated
          public static final String SSL_SESSION

      Deprecated. Use getter methods
      See Also:
        Constant Field Values

    - #### HTTP_REQUEST

          @Deprecated
          public static final String HTTP_REQUEST

      Deprecated. Use getter methods
      See Also:
        Constant Field Values

    - #### HTTP_RESPONSE

          @Deprecated
          public static final String HTTP_RESPONSE

      Deprecated. Use getter methods
      See Also:
        Constant Field Values

  - ### 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. Use `cast(HttpContext)`.

    - #### 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`

Copyright © 2005–2021 The Apache Software Foundation. All rights reserved.