Top Description Fields Constructors Methods
org.apache.hc.client5.http.impl

public Class DefaultClientConnectionReuseStrategy

extends DefaultConnectionReuseStrategy
Class Inheritance
Annotations
@Contract
threading:STATELESS
Imports
org.apache.hc.core5.annotation.Contract, .ThreadingBehavior, org.apache.hc.core5.http.HttpRequest, .HttpResponse, .HttpStatus, .Method, org.apache.hc.core5.http.impl.DefaultConnectionReuseStrategy, org.apache.hc.core5.http.protocol.HttpContext

Extension of core DefaultConnectionReuseStrategy that treats CONNECT method exchanges involved in proxy tunnelling as a special case.
Since
5.2

Field Summary

Modifier and TypeField and Description
public static final DefaultClientConnectionReuseStrategy

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public boolean
keepAlive(final HttpRequest
The last request transmitted over that connection.
request
,
final HttpResponse
The last response transmitted over that connection.
response
,
final HttpContext
the context in which the connection is being used.
context
)

Overrides org.apache.hc.core5.http.impl.DefaultConnectionReuseStrategy.keepAlive.

Implements org.apache.hc.core5.http.ConnectionReuseStrategy.keepAlive.

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

Field Detail

INSTANCEback to summary
public static final DefaultClientConnectionReuseStrategy INSTANCE

Hides org.apache.hc.core5.http.impl.DefaultConnectionReuseStrategy.INSTANCE.

Constructor Detail

DefaultClientConnectionReuseStrategyback to summary
public DefaultClientConnectionReuseStrategy()

Method Detail

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

Overrides org.apache.hc.core5.http.impl.DefaultConnectionReuseStrategy.keepAlive.

Implements org.apache.hc.core5.http.ConnectionReuseStrategy.keepAlive.

Doc from org.apache.hc.core5.http.ConnectionReuseStrategy.keepAlive.

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

Annotations
@Override