fixed keepalive min value

pull/1/head
Michael Peter Christen 12 years ago
parent 5ec5be5769
commit 94b565ea0d

@ -162,7 +162,7 @@ public class HTTPClient {
builder.setDefaultCookieStore(null); builder.setDefaultCookieStore(null);
builder.disableCookieManagement(); builder.disableCookieManagement();
// add cutom keep alive strategy // add custom keep alive strategy
builder.setKeepAliveStrategy(customKeepAliveStrategy()); builder.setKeepAliveStrategy(customKeepAliveStrategy());
// ask for gzip // ask for gzip
@ -738,15 +738,9 @@ public class HTTPClient {
private static ConnectionKeepAliveStrategy customKeepAliveStrategy() { private static ConnectionKeepAliveStrategy customKeepAliveStrategy() {
return new DefaultConnectionKeepAliveStrategy() { return new DefaultConnectionKeepAliveStrategy() {
@Override @Override
public long getKeepAliveDuration(HttpResponse response, public long getKeepAliveDuration(HttpResponse response, HttpContext context) {
HttpContext context) {
long keepAlive = super.getKeepAliveDuration(response, context); long keepAlive = super.getKeepAliveDuration(response, context);
if (keepAlive < 1) { return Math.min(Math.max(keepAlive, 5000), 25000);
// Keep connections alive 5 seconds if a keep-alive value
// has not be explicitly set by the server
keepAlive = 5000;
}
return Math.min(keepAlive, 25000);
} }
}; };
} }

Loading…
Cancel
Save