From 94b565ea0db0f0a8a90294a8d0d45765befcc491 Mon Sep 17 00:00:00 2001 From: Michael Peter Christen Date: Fri, 15 Nov 2013 15:37:01 +0100 Subject: [PATCH] fixed keepalive min value --- source/net/yacy/cora/protocol/http/HTTPClient.java | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/source/net/yacy/cora/protocol/http/HTTPClient.java b/source/net/yacy/cora/protocol/http/HTTPClient.java index 5cb3f4727..56b167a95 100644 --- a/source/net/yacy/cora/protocol/http/HTTPClient.java +++ b/source/net/yacy/cora/protocol/http/HTTPClient.java @@ -162,7 +162,7 @@ public class HTTPClient { builder.setDefaultCookieStore(null); builder.disableCookieManagement(); - // add cutom keep alive strategy + // add custom keep alive strategy builder.setKeepAliveStrategy(customKeepAliveStrategy()); // ask for gzip @@ -738,15 +738,9 @@ public class HTTPClient { private static ConnectionKeepAliveStrategy customKeepAliveStrategy() { return new DefaultConnectionKeepAliveStrategy() { @Override - public long getKeepAliveDuration(HttpResponse response, - HttpContext context) { + 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 Math.min(keepAlive, 25000); + return Math.min(Math.max(keepAlive, 5000), 25000); } }; }