client.setConnectionReuseStrategy(new NoConnectionReuseStrategy());
} else {
client.setConnectionReuseStrategy(new DefaultConnectionReuseStrategy());
// either keep alive based on response header Keep-Alive,
// or if the server can keep a persistent connection (-1), then override based on client's configuration
client.setKeepAliveStrategy(new DefaultConnectionKeepAliveStrategy() {
@Override
public long getKeepAliveDuration(HttpResponse response, HttpContext context) {
final long duration = super.getKeepAliveDuration(response, context);
return (duration == -1) ? keepAlive : duration;
}