Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

corrected YaCy version in HTTP User-Agent

danielr8c5f062e0b44
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 {