From 65f383e70ba95d4e5301943062b280c7ef508ef1 Mon Sep 17 00:00:00 2001 From: orbiter Date: Thu, 22 Apr 2010 22:10:19 +0000 Subject: [PATCH] some adjustments to the httpc after testing with a very slow httpd git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@6831 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- source/de/anomic/http/client/Client.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/source/de/anomic/http/client/Client.java b/source/de/anomic/http/client/Client.java index d51c72751..fd1856c93 100644 --- a/source/de/anomic/http/client/Client.java +++ b/source/de/anomic/http/client/Client.java @@ -119,7 +119,6 @@ public class Client { conManager.shutdown(); } conManager = new MultiThreadedHttpConnectionManager(); - apacheHttpClient = new HttpClient(conManager); /** * set options for connection manager @@ -135,6 +134,7 @@ public class Client { conManager.getParams().setMaxConnectionsPerHost(localHostConfiguration, 100); conManager.getParams().setReceiveBufferSize(16 * 1024 * 1024); // set this high to avoid storage in temporary files + apacheHttpClient = new HttpClient(conManager); // only one retry apacheHttpClient.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(1, false)); @@ -233,6 +233,7 @@ public class Client { apacheHttpClient.getParams().setIntParameter(HttpMethodParams.SO_TIMEOUT, timeout); apacheHttpClient.getParams().setIntParameter(HttpMethodParams.HEAD_BODY_CHECK_TIMEOUT, timeout); apacheHttpClient.setConnectionTimeout(timeout); + apacheHttpClient.setTimeout(60000); } /** @@ -475,7 +476,7 @@ public class Client { DigestURI url = new DigestURI(method.getURI().toString(), null); if (url.hash() != null) Latency.slowdown(new String(url.hash()).substring(6), url.getHost()); ConnectionInfo.removeConnection(generateConInfo(method)); - throw e; + throw new IOException(e.getMessage()); } catch (final IOException e) { // cleanUp statistics DigestURI url = new DigestURI(method.getURI().toString(), null); @@ -488,6 +489,9 @@ public class Client { if (url.hash() != null) Latency.slowdown(new String(url.hash()).substring(6), url.getHost()); ConnectionInfo.removeConnection(generateConInfo(method)); throw new IOException(e.getMessage()); + } finally { + // cleanUp statistics + ConnectionInfo.removeConnection(generateConInfo(method)); } if (Log.isFinest("HTTPC")) Log.logFinest("HTTPC", "<-" + method.hashCode() + " response headers " + Arrays.toString(method.getResponseHeaders()));