diff --git a/archiva-modules/archiva-base/archiva-proxy-common/src/main/java/org/apache/archiva/proxy/common/DefaultWagonFactory.java b/archiva-modules/archiva-base/archiva-proxy-common/src/main/java/org/apache/archiva/proxy/common/DefaultWagonFactory.java
index 8bf469a7a..629eda0e6 100755
--- a/archiva-modules/archiva-base/archiva-proxy-common/src/main/java/org/apache/archiva/proxy/common/DefaultWagonFactory.java
+++ b/archiva-modules/archiva-base/archiva-proxy-common/src/main/java/org/apache/archiva/proxy/common/DefaultWagonFactory.java
@@ -19,14 +19,17 @@ package org.apache.archiva.proxy.common;
* under the License.
*/
-import org.apache.archiva.common.plexusbridge.PlexusSisuBridge;
import org.apache.commons.lang.StringUtils;
import org.apache.maven.wagon.Wagon;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;
import javax.inject.Inject;
+import java.lang.reflect.Method;
+import java.util.Properties;
/**
* @author Olivier Lamy
@@ -39,6 +42,8 @@ public class DefaultWagonFactory
private ApplicationContext applicationContext;
+ private Logger logger = LoggerFactory.getLogger( getClass() );
+
private DebugTransferListener debugTransferListener = new DebugTransferListener();
@Inject
@@ -56,6 +61,7 @@ public class DefaultWagonFactory
Wagon wagon = applicationContext.getBean( protocol, Wagon.class );
wagon.addTransferListener( debugTransferListener );
+ configureUserAgent( wagon );
return wagon;
}
catch ( BeansException e )
@@ -63,4 +69,28 @@ public class DefaultWagonFactory
throw new WagonFactoryException( e.getMessage(), e );
}
}
+
+ protected void configureUserAgent( Wagon wagon )
+ {
+ try
+ {
+ Class clazz = wagon.getClass();
+ Method getHttpHeaders = clazz.getMethod( "getHttpHeaders", null );
+
+ Properties headers = (Properties) getHttpHeaders.invoke( wagon, null );
+ if ( headers == null )
+ {
+ headers = new Properties();
+ }
+ headers.put( "User-Agent", "Java" );
+ Method setHttpHeaders = clazz.getMethod( "setHttpHeaders", new Class[]{ Properties.class } );
+ setHttpHeaders.invoke( wagon, headers );
+
+ logger.debug( "http headers set to: {}", headers );
+ }
+ catch ( Exception e )
+ {
+ logger.warn( "fail to configure User-Agent: " + e.getMessage(), e );
+ }
+ }
}
diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/DownloadRemoteIndexTask.java b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/DownloadRemoteIndexTask.java
index b348ab2f4..fc1d4b069 100644
--- a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/DownloadRemoteIndexTask.java
+++ b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/DownloadRemoteIndexTask.java
@@ -32,6 +32,7 @@ import org.apache.maven.index.updater.IndexUpdater;
import org.apache.maven.index.updater.ResourceFetcher;
import org.apache.maven.wagon.ConnectionException;
import org.apache.maven.wagon.ResourceDoesNotExistException;
+import org.apache.maven.wagon.StreamWagon;
import org.apache.maven.wagon.TransferFailedException;
import org.apache.maven.wagon.Wagon;
import org.apache.maven.wagon.authentication.AuthenticationException;
@@ -128,7 +129,7 @@ public class DownloadRemoteIndexTask
new URL( this.remoteRepository.getUrl() ).getProtocol() + ( ( this.networkProxy != null
&& this.networkProxy.isUseNtlm() ) ? "-ntlm" : "" );
- final Wagon wagon = wagonFactory.getWagon( wagonProtocol );
+ final StreamWagon wagon = (StreamWagon) wagonFactory.getWagon( wagonProtocol );
int timeoutInMilliseconds = remoteRepository.getTimeout() * 1000;
// FIXME olamy having 2 config values
wagon.setReadTimeout( timeoutInMilliseconds );
diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/test/tomcat/log4j.xml b/archiva-modules/archiva-web/archiva-webapp-js/src/test/tomcat/log4j.xml
index 934409da7..76dead0e1 100644
--- a/archiva-modules/archiva-web/archiva-webapp-js/src/test/tomcat/log4j.xml
+++ b/archiva-modules/archiva-web/archiva-webapp-js/src/test/tomcat/log4j.xml
@@ -46,7 +46,15 @@
-
+
+
+
+
+