Top Description Methods
org.apache.hc.core5.http

public Interface ConnectionReuseStrategy

Known Direct Implementers
org.apache.hc.core5.http.impl.DefaultConnectionReuseStrategy
Annotations
@Contract
threading:STATELESS
Imports
org.apache.hc.core5.annotation.Contract, .ThreadingBehavior, org.apache.hc.core5.http.protocol.HttpContext

Interface for deciding whether a connection can be re-used for subsequent requests and should be kept alive.

Implementations of this interface must be thread-safe. Access to shared data must be synchronized as methods of this interface may be executed from multiple threads.

Since
4.0

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if the connection is allowed to be reused, or false if it MUST NOT be reused
keepAlive
(HttpRequest
The last request transmitted over that connection.
request
,
HttpResponse
The last response transmitted over that connection.
response
,
HttpContext
the context in which the connection is being used.
context
)

Decides whether a connection can be kept open after a request.

Method Detail

keepAliveback to summary
public boolean keepAlive(HttpRequest request, HttpResponse response, HttpContext context)

Decides whether a connection can be kept open after a request. If this method returns false, the caller MUST close the connection to correctly comply with the HTTP protocol. If it returns true, the caller SHOULD attempt to keep the connection open for reuse with another request.

One can use the HTTP context to retrieve additional objects that may be relevant for the keep-alive strategy: the actual HTTP connection, the original HTTP request, target host if known, number of times the connection has been reused already and so on.

If the connection is already closed, false is returned. The stale connection check MUST NOT be triggered by a connection reuse strategy.

Parameters
request:HttpRequest

The last request transmitted over that connection.

response:HttpResponse

The last response transmitted over that connection.

context:HttpContext

the context in which the connection is being used.

Returns:boolean

true if the connection is allowed to be reused, or false if it MUST NOT be reused