org.apache.hc.core5.http.io

## Interface BHttpConnection

- All Superinterfaces:
    AutoCloseable, Closeable, HttpConnection, ModalCloseable, SocketModalCloseable
  All Known Subinterfaces:
    HttpClientConnection, HttpServerConnection
  All Known Implementing Classes:
    DefaultBHttpClientConnection, DefaultBHttpServerConnection, LoggingBHttpClientConnection, LoggingBHttpServerConnection

      public interface BHttpConnection
      extends HttpConnection

  Abstract blocking HTTP connection interface.
  Since:
    5.0

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `flush()` Writes out all pending buffered data over the open connection.
    `boolean` | `isDataAvailable(Timeout timeout)` Checks if input data is available from the connection.
    `boolean` | `isStale()` Checks whether this connection has gone down.

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

    - #### isDataAvailable

          boolean isDataAvailable(Timeout timeout)
                           throws IOException

      Checks if input data is available from the connection. May wait for the specified time until some data becomes available. Note that some implementations may completely ignore the timeout parameter.
      Parameters:
        `timeout` - the maximum time to wait for data
      Returns:
        true if data is available; false if there was no data available even after waiting for `timeout`.
      Throws:
        `IOException` - if an error happens on the connection

    - #### isStale

          boolean isStale()
                   throws IOException

      Checks whether this connection has gone down. Network connections may get closed during some time of inactivity for several reasons. The next time a read is attempted on such a connection it will throw an IOException. This method tries to alleviate this inconvenience by trying to find out if a connection is still usable. Implementations may do that by attempting a read with a very small timeout. Thus this method may block for a small amount of time before returning a result. It is therefore an expensive operation.
      Returns:
        `true` if attempts to use this connection are likely to fail and this connection should be closed, or `false` if they are likely to succeed
      Throws:
        `IOException`

    - #### flush

          void flush()
              throws IOException

      Writes out all pending buffered data over the open connection.
      Throws:
        `IOException` - in case of an I/O error

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