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

  Implementation of `HttpContext` that provides convenience setters for user assignable attributes and getter for readable attributes.
  Since:
    4.3

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `CONNECTION_ENDPOINT` Attribute name of a `EndpointDetails` object that represents the actual connection endpoint details.
    `static String` | `HTTP_REQUEST` Attribute name of a `HttpRequest` object that represents the actual HTTP request.
    `static String` | `HTTP_RESPONSE` Attribute name of a `HttpResponse` object that represents the actual HTTP response.
    `static String` | `SSL_SESSION` Attribute name of a `SSLSession` object that represents the actual connection endpoint details.

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

      `RESERVED_PREFIX`

  - ### Constructor Summary

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

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static HttpCoreContext` | `adapt(HttpContext context)`
    `static HttpCoreContext` | `create()`
    `Object` | `getAttribute(String id)` Obtains attribute with the given name.
    `<T> T` | `getAttribute(String attribname, Class<T> clazz)`
    `EndpointDetails` | `getEndpointDetails()`
    `ProtocolVersion` | `getProtocolVersion()` Returns protocol version used in this context.
    `HttpRequest` | `getRequest()`
    `HttpResponse` | `getResponse()`
    `SSLSession` | `getSSLSession()`
    `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` | `setProtocolVersion(ProtocolVersion version)` Sets protocol version used in this context.

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

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

- - ### Field Detail

    - #### CONNECTION_ENDPOINT

          public static final String CONNECTION_ENDPOINT

      Attribute name of a `EndpointDetails` object that represents the actual connection endpoint details.
      See Also:
        Constant Field Values

    - #### SSL_SESSION

          public static final String SSL_SESSION

      Attribute name of a `SSLSession` object that represents the actual connection endpoint details.
      See Also:
        Constant Field Values

    - #### HTTP_REQUEST

          public static final String HTTP_REQUEST

      Attribute name of a `HttpRequest` object that represents the actual HTTP request.
      See Also:
        Constant Field Values

    - #### HTTP_RESPONSE

          public static final String HTTP_RESPONSE

      Attribute name of a `HttpResponse` object that represents the actual HTTP response.
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### HttpCoreContext

          public HttpCoreContext(HttpContext context)

    - #### HttpCoreContext

          public HttpCoreContext()

  - ### Method Detail

    - #### create

          public static HttpCoreContext create()

    - #### adapt

          public static HttpCoreContext adapt(HttpContext context)

    - #### getProtocolVersion

          public ProtocolVersion getProtocolVersion()

      Description copied from interface: `HttpContext`
      Returns protocol version used in this context.
      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 attribname,
                           Class<T> clazz)

    - #### getSSLSession

          public SSLSession getSSLSession()

      Since:
        5.0

    - #### getEndpointDetails

          public EndpointDetails getEndpointDetails()

      Since:
        5.0

    - #### getRequest

          public HttpRequest getRequest()

    - #### getResponse

          public HttpResponse getResponse()

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