org.apache.hc.core5.http

## Interface HttpConnection

- All Superinterfaces:
    AutoCloseable, Closeable, ModalCloseable, SocketModalCloseable
  All Known Subinterfaces:
    BHttpConnection, HttpClientConnection, HttpConnectionEventHandler, HttpServerConnection
  All Known Implementing Classes:
    ClientH2IOEventHandler, ClientH2StreamMultiplexer, ClientHttp1IOEventHandler, ClientHttp1StreamDuplexer, ClientHttpProtocolNegotiator, DefaultBHttpClientConnection, DefaultBHttpServerConnection, H2OnlyClientProtocolNegotiator, H2OnlyServerHttpProtocolNegotiator, LoggingBHttpClientConnection, LoggingBHttpServerConnection, ServerH2IOEventHandler, ServerH2StreamMultiplexer, ServerHttp1IOEventHandler, ServerHttp1StreamDuplexer, ServerHttpProtocolNegotiator

      public interface HttpConnection
      extends SocketModalCloseable

  A generic HTTP connection, useful on client and server side.
  Since:
    4.0

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close()` Closes this connection gracefully.
    `EndpointDetails` | `getEndpointDetails()` Returns this connection's endpoint details.
    `SocketAddress` | `getLocalAddress()` Returns this connection's local address or `null` if it is not bound yet.
    `ProtocolVersion` | `getProtocolVersion()` Returns this connection's protocol version or `null` if unknown.
    `SocketAddress` | `getRemoteAddress()` Returns this connection's remote address or `null` if it is not connected yet or unconnected.
    `SSLSession` | `getSSLSession()` Returns this connection's SSL session or `null` if TLS has not been activated.
    `boolean` | `isOpen()` Checks if this connection is open.

    - ### Methods inherited from interface org.apache.hc.core5.http.SocketModalCloseable

      `getSocketTimeout, setSocketTimeout`

    - ### Methods inherited from interface org.apache.hc.core5.io.ModalCloseable

      `close`

- - ### Method Detail

    - #### close

          void close()
                     throws IOException

      Closes this connection gracefully. This method will attempt to flush the internal output buffer prior to closing the underlying socket. This method MUST NOT be called from a different thread to force shutdown of the connection. Use `shutdown` instead.
      Specified by:
        `close` in interface `AutoCloseable`
      Specified by:
        `close` in interface `Closeable`
      Throws:
        `IOException`

    - #### getEndpointDetails

          EndpointDetails getEndpointDetails()

      Returns this connection's endpoint details.
      Returns:
        this connection's endpoint details.

    - #### getLocalAddress

          SocketAddress getLocalAddress()

      Returns this connection's local address or `null` if it is not bound yet.
      Returns:
        this connection's local address or `null` if it is not bound yet.
      Since:
        5.0

    - #### getRemoteAddress

          SocketAddress getRemoteAddress()

      Returns this connection's remote address or `null` if it is not connected yet or unconnected.
      Returns:
        this connection's remote address or `null` if it is not connected yet or unconnected.
      Since:
        5.0

    - #### getProtocolVersion

          ProtocolVersion getProtocolVersion()

      Returns this connection's protocol version or `null` if unknown.
      Returns:
        this connection's protocol version or `null` if unknown.
      Since:
        5.0

    - #### getSSLSession

          SSLSession getSSLSession()

      Returns this connection's SSL session or `null` if TLS has not been activated.
      Returns:
        this connection's SSL session or `null` if TLS has not been activated.

    - #### isOpen

          boolean isOpen()

      Checks if this connection is open.
      Returns:
        true if it is open, false if it is closed.

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