From 8c5f062e0b443c244bfb02369578047a47bd3923 Mon Sep 17 00:00:00 2001 From: danielr Date: Sun, 4 May 2008 12:18:00 +0000 Subject: [PATCH] corrected YaCy version in HTTP User-Agent git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@4762 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- .../de/anomic/http/JakartaCommonsHttpClient.java | 14 +++++++------- source/yacy.java | 8 ++++++++ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/source/de/anomic/http/JakartaCommonsHttpClient.java b/source/de/anomic/http/JakartaCommonsHttpClient.java index aca7905d1..0a7e13765 100644 --- a/source/de/anomic/http/JakartaCommonsHttpClient.java +++ b/source/de/anomic/http/JakartaCommonsHttpClient.java @@ -79,13 +79,6 @@ public class JakartaCommonsHttpClient { /** * set options for client */ - // set user-agent - final yacyVersion thisversion = yacyVersion.thisVersion(); - final String userAgent = "yacy/" + ((thisversion == null) ? "0.0" : thisversion.releaseNr) + - " (www.yacy.net; " + de.anomic.http.HttpClient.getSystemOST() + ") " + - // last ; must be before location (this is parsed) - getCurrentUserAgent().replace(';', ':'); - apacheHttpClient.getParams().setParameter(HttpMethodParams.USER_AGENT, userAgent); // only one retry apacheHttpClient.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(1, false)); @@ -566,6 +559,13 @@ public class JakartaCommonsHttpClient { return (String) apacheHttpClient.getParams().getParameter(HttpMethodParams.USER_AGENT); } + /** + * @param userAgent + */ + public static void setUserAgent(final String userAgent) { + apacheHttpClient.getParams().setParameter(HttpMethodParams.USER_AGENT, userAgent); + } + /** * number of active connections * diff --git a/source/yacy.java b/source/yacy.java index 40e14fa80..6695dddba 100644 --- a/source/yacy.java +++ b/source/yacy.java @@ -326,6 +326,14 @@ public final class yacy { int deleteOldDownloadsAfterDays = (int) sb.getConfigLong("update.deleteOld", 30); yacyVersion.deleteOldDownloads(sb.releasePath, deleteOldDownloadsAfterDays ); + // set user-agent + final yacyVersion thisversion = yacyVersion.thisVersion(); + final String userAgent = "yacy/" + ((thisversion == null) ? "0.0" : thisversion.releaseNr) + + " (www.yacy.net; " + de.anomic.http.HttpClient.getSystemOST() + ") " + + // last ; must be before location (this is parsed) + JakartaCommonsHttpClient.getCurrentUserAgent().replace(';', ':'); + JakartaCommonsHttpClient.setUserAgent(userAgent); + // start main threads final String port = sb.getConfig("port", "8080"); try {