org.apache.hc.core5.http.io

## Interface HttpClientConnection

- All Superinterfaces:
    AutoCloseable, BHttpConnection, Closeable, HttpConnection, ModalCloseable, SocketModalCloseable
  All Known Implementing Classes:
    DefaultBHttpClientConnection, LoggingBHttpClientConnection

      public interface HttpClientConnection
      extends BHttpConnection

  A client-side HTTP connection, which can be used for sending requests and receiving responses.
  Since:
    4.0

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `isConsistent()` Checks whether this connection is in a consistent state.
    `void` | `receiveResponseEntity(ClassicHttpResponse response)` Receives the next response entity available from this connection and attaches it to an existing HttpResponse object.
    `ClassicHttpResponse` | `receiveResponseHeader()` Receives the request line and headers of the next response available from this connection.
    `void` | `sendRequestEntity(ClassicHttpRequest request)` Sends the request entity over the connection.
    `void` | `sendRequestHeader(ClassicHttpRequest request)` Sends the request line and all headers over the connection.
    `void` | `terminateRequest(ClassicHttpRequest request)` Terminates request prematurely potentially leaving the connection in a inconsistent state.

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

      `flush, isDataAvailable, isStale`

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

      `close, getEndpointDetails, getLocalAddress, getProtocolVersion, getRemoteAddress, getSSLSession, isOpen`

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

    - #### isConsistent

          boolean isConsistent()

      Checks whether this connection is in a consistent state.
      Returns:
        `true` if the connection is known to be in a inconsistent state and cannot be re-used.
      Since:
        5.0
      See Also:
        `terminateRequest(ClassicHttpRequest)`

    - #### sendRequestHeader

          void sendRequestHeader(ClassicHttpRequest request)
                          throws HttpException,
                                 IOException

      Sends the request line and all headers over the connection.
      Parameters:
        `request` - the request whose headers to send.
      Throws:
        `HttpException` - in case of HTTP protocol violation
        `IOException` - in case of an I/O error

    - #### terminateRequest

          void terminateRequest(ClassicHttpRequest request)
                         throws HttpException,
                                IOException

      Terminates request prematurely potentially leaving the connection in a inconsistent state.
      Parameters:
        `request` - the request to be terminated prematurely.
      Throws:
        `HttpException`
        `IOException`
      Since:
        5.0
      See Also:
        `isConsistent()`

    - #### sendRequestEntity

          void sendRequestEntity(ClassicHttpRequest request)
                          throws HttpException,
                                 IOException

      Sends the request entity over the connection.
      Parameters:
        `request` - the request whose entity to send.
      Throws:
        `HttpException` - in case of HTTP protocol violation
        `IOException` - in case of an I/O error

    - #### receiveResponseHeader

          ClassicHttpResponse receiveResponseHeader()
                                             throws HttpException,
                                                    IOException

      Receives the request line and headers of the next response available from this connection. The caller should examine the HttpResponse object to find out if it should try to receive a response entity as well.
      Returns:
        a new HttpResponse object with status line and headers initialized or `null` if the connection has been closed by the opposite endpoint.
      Throws:
        `HttpException` - in case of HTTP protocol violation
        `IOException` - in case of an I/O error

    - #### receiveResponseEntity

          void receiveResponseEntity(ClassicHttpResponse response)
                              throws HttpException,
                                     IOException

      Receives the next response entity available from this connection and attaches it to an existing HttpResponse object.
      Parameters:
        `response` - the response to attach the entity to
      Throws:
        `HttpException` - in case of HTTP protocol violation
        `IOException` - in case of an I/O error

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