ConnectionKeepAliveStrategy

// for HttpClient 4.x

this.keepAliveStrategy = new DefaultConnectionKeepAliveStrategy() {

@Override

public long getKeepAliveDuration(HttpResponse response,

HttpContext context) {

long keepAlive = super.getKeepAliveDuration(response, context);

if (keepAlive == -1) {

// Keep connections alive 5 seconds if a keep-alive

// value

// has not be explicitly set by the server

keepAlive = 5000;

}

return keepAlive;

}

};