Last active
May 17, 2020 12:01
-
-
Save dhaval201279/95429d53915631f84fad745d1ebeb4fd to your computer and use it in GitHub Desktop.
Http client config with custom defined keep alive strategy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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