Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Http client config with custom defined keep alive strategy
private ConnectionKeepAliveStrategy connectionKeepAliveStrategy() {
return new DefaultConnectionKeepAliveStrategy() {
@Override
public long getKeepAliveDuration(final HttpResponse response, final HttpContext context) {
long keepAliveDuration = super.getKeepAliveDuration(response, context);
if (keepAliveDuration < 0) {
keepAliveDuration = DEFAULT_KEEP_ALIVE_TIME_MILLIS;
} else if (keepAliveDuration > MAX_KEEP_ALIVE_TIME_MILLIS) {
keepAliveDuration = MAX_KEEP_ALIVE_TIME_MILLIS;
}
return keepAliveDuration;
}
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.