Package org.apache.hc.core5.http.io
Interface BHttpConnection
- All Superinterfaces:
AutoCloseable
,Closeable
,HttpConnection
,ModalCloseable
,SocketModalCloseable
- All Known Subinterfaces:
HttpClientConnection
,HttpServerConnection
- All Known Implementing Classes:
BHttpConnectionBase
,DefaultBHttpClientConnection
,DefaultBHttpServerConnection
,LoggingBHttpClientConnection
,LoggingBHttpServerConnection
Abstract blocking HTTP connection interface.
- Since:
- 5.0
-
Method Summary
Modifier and TypeMethodDescriptionvoid
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.io.ModalCloseable
close
Methods inherited from interface org.apache.hc.core5.http.SocketModalCloseable
getSocketTimeout, setSocketTimeout
-
Method Details
-
isDataAvailable
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
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, orfalse
if they are likely to succeed- Throws:
IOException
-
flush
Writes out all pending buffered data over the open connection.- Throws:
IOException
- in case of an I/O error
-